Page 1 of 1

Image Resize Problem

Posted: Thu Mar 20, 2003 5:07 pm
by mwaw
I want to resize a 400 x 300 px JPEG image to 200 x 150 px. However, when I use the code below I always get an error:

"Warning: imagejpeg() [function.imagejpeg]: Unable to open 'images/products/test2.jpg' for writing in /usr/local/psa/home/vhosts/lezazou.com/httpdocs/ImageSize.php on line 44"

This is the code I am using:

Code: Select all

<?php 
$src_img = imagecreatefromjpeg("images/products/test.jpg"); 
$dst_img = imagecreate(200,150); 
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 200, 150, 400, 300); 
imagejpeg($dst_img, 'images/products/test2.jpg', '75'); 
imagedestroy($src_img); 
imagedestroy($dst_img); 
?>

Note: I cannot use imagecreatetruecolor() or imagecopyresample() due to host limations. I understand the resized image will have poor quality.

Any help would be appreciated

Posted: Thu Mar 20, 2003 5:36 pm
by patrikG
Have you checked the chmod on the directory you are reading from and writing to?

Two Heads Are Better Than One!

Posted: Thu Mar 20, 2003 5:47 pm
by mwaw
Duh...

Yeah, that fixed it.

I appreciate your help. I'm not always this dumb - I promise!

Mike