I have been using the following code to resize pictures without any problems. I now need to save a copy of the thumb, to a sub directory on the server.
I cannot get ImageJPEG to save anything to the server.
What am I doing wrong and is it possible to both save and display the image from this script?
Keith
I cannot get ImageJPEG to save anything to the server.
What am I doing wrong and is it possible to both save and display the image from this script?
Code:
<?php
$img_name=$_GET['imnam'];
$max_wid=$_GET['maxwid'];
$max_ite=$_GET['maxhi'];
$max_width = $maxwid; // maximum x aperture in pixels
$max_height = $maxhi; // maximum y aperture in pixels
$size=GetImageSize($img_name);
$width_ratio = (double) ($size[0] / $max_width);
$height_ratio = (double) ($size[1] / $max_height);
if($width_ratio >=$height_ratio)
{
$ratio = $width_ratio;
}
else
{
$ratio = $height_ratio;
}
$new_width = ($size[0] / $ratio);
$new_height = ($size[1] / $ratio);
$src_img = ImageCreateFromJPEG($img_name);
$thumb = ImageCreateTrueColor($new_width,$new_height);
ImageCopyResampled($thumb, $src_img, 0,0,0,0,$new_width,$new_height,$size[0],$size[1]);
[red]
//$dir="emimag/newpic.jpg";
//$quality=60;
//ImageJPEG($thumb,$dir , $quality);
[/red]
ImageJPEG($thumb);
ImageDestroy($src_img);
ImageDestroy($thumb);
?>
Keith