Forum Moderators: coopster

Message Too Old, No Replies

Using GD to Resize

         

TheRealTerry

2:03 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



I've tried several ways to write this script and everytime no file is written. I've double-checked and GD is installed and enabled and the permissions on the write folder are okay. All this should do is take a file that is uploaded and resize it to a width of 230pixels and save it (the file upload works fine, tested and proven.) Can anyone see the error of my ways here?

$img_name = $filename; //from earlier in script
$max_width = "230";
$image_details = getimagesize("$img_name");
$imagesize_x = $image_details[0];
$imagesize_y = $image_details[1];
$thumb_width = $maxwidth;
$thumb_height = (int)(($max_width*$imagesize_y)/imagesize_x);
$source = imagecreatefromjpeg($img_name);
$dest = imagecreatetruecolor($thumb_width, $thumb_height);
$final = imagecopyresampled ($dest, $source, 0, 0, 0, 0, $thumb_width, $thumb_height, $imagesize_x, $imagesize_y);
imagejpeg($final, "savenew.jpg", 90);
imagedestroy($dest);
imagedestroy($source);

Birdman

2:26 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My first guess is that the path in the image_jpeg() function is wrong. It is relative in your example, but it should be the full server path to the file.

Like on my server, it would be:

/home/username/public_html/thumbnails/savenow.jpg

Here's a similar script I wrote a long time ago. It's a bit sloppy but may give you some insight.

[webmasterworld.com...] scroll dow a bit to get to it.