Page 1 of 1

image quality

Posted: Thu Jun 10, 2010 10:33 pm
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

Re: image quality

Posted: Fri Jun 11, 2010 10:27 am
by pickle
Ya, you can't just change the quality of an image. You have to create a new image.