PDA

View Full Version : Preserver Quality in ImageJPEG()


jwlai
04-27-2001, 05:23 AM
PHP Gurus,

I am using PHP image functions to add url of my website to my photos. Basically, I use ImageCopyMerge() to merge original JPG file & another[nbsp][nbsp]image file which contain my url. Then output this new photo by ImageJPEG().

Here is an example after merge:
http://www.zhoujie.com/photo/showpic.php?InFile=../photo3/p03.jpg

RIght now I am using default quality setting with ImageJPEG, which is 75. The picture quality is degraded since this setting is lower than original file setting.

I know I can control the JPEG compress rate when I call ImageJPEG(). However, every photo in my site has different compressing rate. I don't want to use a universal value, I just want to use the same compression rate as the original JPEG file.

How do I get the compression rate from my original JPEG file?


------------------
Jerry
Taipei, Taiwan

janderk
04-27-2001, 07:14 AM
JPEG image always degrade when resaving multiple times because they are a lossy compression format. For top quality images you typically want to save them only once as JPEG after all image processing is done.

If you site is even mildly popular this scripts is gonna put a huge load on the server's processor. Image processing and JPEG compression is *very* demanding and not a task you would typically perform in a shared server environment.

Make sure that you process you images only once and not for every page "on the fly". I'd say your best option is to process your images offline and upload the images with the links in them.

You will need a batch image processing program. I'd suggest Arles Image Web Page Creator:

http://www.digitaldutch.com/arles/

But I'm biased, because we make the thing.

Jan Derk

jwlai
04-27-2001, 07:36 AM
Jan,

Thanks for the advice.
I am also concern about server load on the image process. Fortunetely, my site is not that popular, not sure I should put :) or :([nbsp][nbsp]
I believe Terra will stop me if I cause any server load problem.

quote from http://www.faqs.org/faqs/jpeg-faq/part1/section-10.html

It turns out that if you decompress and recompress an image at the same
quality setting first used, relatively little further degradation occurs.

This is the reason I want to compress it to the same level as before.

Actually, if I do it locally, it will be very easy to get this result. Maybe I should go with your suggestion to process my images offline and upload the images again.

------------------
Jerry
Taipei, Taiwan
[This message has been edited by jwlai (edited 04-27-01@06:37 am)]