Image Resize Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mwaw
Forum Newbie
Posts: 19
Joined: Sun Aug 11, 2002 12:31 am
Location: California

Image Resize Problem

Post 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
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Have you checked the chmod on the directory you are reading from and writing to?
mwaw
Forum Newbie
Posts: 19
Joined: Sun Aug 11, 2002 12:31 am
Location: California

Two Heads Are Better Than One!

Post by mwaw »

Duh...

Yeah, that fixed it.

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

Mike
Post Reply