image quality

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
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

image quality

Post by m2babaey »

Hi
I upload a jpg file, also create a thumbnail from it and store both
I want to set quality to 80 for both
for thumbnail, I think if I add a 80 at the end of thumbnail creation code, it'll work

Code: Select all

$sourceImage = imagecreatefromjpeg("$sourcePath/$sourceName");
$sourceWidth = imagesx($sourceImage);
$sourceHeight = imagesy($sourceImage);

$targetImage = imagecreate($thumbWidth,$thumbHeight);
imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,
$thumbWidth,imagesx($sourceImage),imagesy($sourceImage));
imagejpeg($targetImage, "$thumbPath/$thumbName",80);
in the manual it said the input for this function comes from another function so for uploading the original file, I cannot set quality directly?
I have to create a thumbnail but the size with original size of the image? to set quality
Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: image quality

Post by pickle »

Ya, you can't just change the quality of an image. You have to create a new image.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply