Hi All
I found some code here in the forum for resizing images and it seems to work but I'm getting a strange result:
Here is the code:
//resize the image
echo "<b>Begin Resize</b><br>";
//set the input variables
// Article thumbnail sizes
$thumb_max_width = 160;
$thumb_max_height = 120;
$thumb_quality = 90;
// read image size
$size = getimagesize($upfile);
echo "File Size: $size<br>";
// read the input file
$input_image = imagecreatefromjpeg($upfile);
echo "Input Image: $input_image<br>";
// compute ratio
$ratio = min($thumb_max_width,$size[0],$thumb_max_height/$size[1]);
echo "Resize Ratio: $ratio<br>";
// create output image
$output_image = ImageCreate(round($size[0] $ratio),round($size[1] $ratio));
echo "Output Image: $output_image<br>";
// resample image
// when using GD 1.x change this to imagecopyresized
imagecopyresized($output_image, $input_image, 0, 0, 0, 0, round($size[0] $ratio), round($size[1] $ratio), $size[0], $size[1]);
//imagecopyresampled($output_image, $input_image, 0, 0, 0, 0, round($size[0] $ratio), round($size[1] $ratio), $size[0], $size[1]);
// create output image
imagejpeg($output_image,$output_file,$thumb_quality);
imagedestroy($input_image);
imagedestroy($output_image);
Here are the output results:
Begin Resize
File Size: Array
Input Image: Resource id #2
Resize Ratio: 0.25
Output Image: Resource id #3
ÿØÿà
snipped out a whole bunch of charaters which I think are the file. It outputs it to the web screen and not back to the directory.
Any ideas?
Russ