Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a new image with ImageJPEG 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
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?

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
 
Check to ensure that the server has permissions to write to the directory you are trying to write to.
Easiest test is to chmod the directory to 777

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Thanks Foamcow - spot on!
Those pesky permissions catch me out again.
I can even get the picture to display after saving so I can get on with the rest of it tomorrow.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top