From an upload script, it moves the file to the appropriate directory and then resizes. The upload and moving is fine, but the script just does not resize it. I want it to make a jpeg file regardless of the file type uploaded.
This is my first time working with image resizing. Any ideas why this might not be working as it should? BTW, this follows SitePoint's article on building a photo gallery script.PHP Code:function resize($width, $height, $quality, $filename) {
// please fill out this form...
list($srcw, $srch, $srct, $srca) = getimagesize($filename);
// strip extensions
$newFileName = preg_replace('/\.[gifjpn]{3}$/', '', $filename, 1);
switch($srct)
{
// gif format
case 1:
$image = @imagecreatefromgif($filename);
break;
// jpg format
case 2:
$image = @imagecreatefromjpeg($filename);
break;
// png format
case 3:
$image = @imagecreatefrompng($filename);
break;
}
$newImage = imagecreatetruecolor($width, $height);
imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $srcw, $srch);
return imagejpeg($newImage, $filename, $quality);
imagedestroy($image);
imagedestroy($newImage);
}






Bookmarks