Well after some help in here I got a resize-function that worked, but now I upgraded to php5.0.0 and suddenly I have a few things that didn't work anymore.
E.g. my rutine to resize an image.
The image type is either image/jpg,-png or -gif - but now all of a sudden the image-mime is x-png or pjpeg and then the routine fails in the line :
$input_image = imagecreatefrom....
Whats wrong now?? - It works on a server with php 4.3.3 ???
$size = getimagesize($input_file);
$imgwidth = $size[0];
$imgheight = $size[1];
$maxwidth = pnModGetVar($ModName,'screenshotwidth');
$maxheight = pnModGetVar($ModName,'screenshotheight');
$quality = pnModGetVar($ModName,'jpegqual');
switch ($size['mime']) {
case 'image/jpeg':
//Read input file
$input_image = imagecreatefromjpeg($input_file);
//Create JPG output file
$output_image = imagecreatefromjpeg($input_file);
//Resample image (GD2.0)
$output_image = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($output_image, $input_image, 0, 0, 0, 0, $newwidth, $newheight, $imgwidth, $imgheight);
//create output image
imagejpeg($output_image, $output_file, $quality); // Output the new PNG
break;
case 'image/png':
//Read input file
$input_image = imagecreatefrompng($input_file);
$output_image = imagecreatefrompng($input_file);
imagecopyresampled($output_image, $input_image, 0, 0, 0, 0, $newwidth, $newheight, $imgwidth, $imgheight); // Resample the original PNG
imagepng($output_image, $output_file, $quality); // Output the new PNG
break;
case 'image/gif':
$input_image = imagecreatefromgif($input_file);
$output_image = imagecreatefromgif($input_file);
imagecopyresized($output_image, $input_image, 0, 0, 0, 0, $newwidth, $newheight, $imgwidth, $imgheight); // Resample the original GIF
imagepng($output_image, $output_file, $quality); // Output the new GIF
break;
default:
break;