Hi, I would like to ask to see if there is anything wrong with my script to create thumbnail image. I thought it was right, but for some reason, it is not working. THank
<?php
#########################################################################################
# PHP Image gallery 0.7.4 by Manijak.
# e-mail: [email]fuad.sabanovic@Gmail.com[/email]
# GD 2 or higher required!
#########################################################################################
$dir = $_GET['dir']; // Get a folder name
$pict = $_GET['pict']; // Get a picture name
$size = GetImageSize($dir . $pict); // Get an array with imagesize
$src_width = $size[0];
$src_height = $size[1];
// Settings for thumbsize
$dst_width = "150";
$dst_height = "150";
$sFileType = strstr($pict, "."); // Extrakting extension
$arrJPEG = array(".jpeg", ".jpg", ".JPG", ".JPEG"); // Setting up arrays with extensions
$arrPNG = array(".PNG", ".png");
// If folder does not exist, create it and give it 755 mode
if(!file_exists($dir.'thumbz'))
{
mkdir($dir.'thumbz',0755);
}
// Making thumbnail
if (in_array($sFileType, $arrJPEG)) // If it is a JPEG file
{
header ("Content-type: image/jpeg");
$src = imagecreatefromjpeg($dir.$pict); // Reading original file
$dst = imagecreatetruecolor($dst_width,$dst_height); // Create empty image
imagecopyresampled($dst,$src,0,0,0,0,$dst_width,$dst_height,$src_width,$src_height); //Copy resized original image to emptyone
imagejpeg($dst); // send to browser
imagejpeg($dst, $dir."thumbz/tb_".$pict, 80); //save thumbnail to filesystem
chmod($dir."thumbz/tb_".$pict, 0755); // Change mode
imagedestroy($dst); // Deletin images from memmory
imagedestroy($src);
}
// Same as above only for PNG's
else if(in_array($sFileType, $arrPNG))
{
header ("Content-type: image/png");
$src = imagecreatefrompng($dir.$pict);
$dst = imagecreatetruecolor($dst_width,$dst_height);
imagecopyresampled($dst,$src,0,0,0,0,$dst_width,$dst_height,$src_width,$src_height);
imagepng($dst);
imagepng($dst, $dir."thumbz/tb_".$pict, 80);
chmod($dir."thumbz/tb_".$pict, 0755);
imagedestroy($dst);
imagedestroy($src);
}
?>