View Full Version : thumbnail compression
Action-N
01-26-2014, 07:06 PM
This is more of a general programming question. In creating thumbnails both jpeg an png accept compression but at different number scale, jpeg 100 an png 9. I have one variable for jpeg an wondered if someone could help with a ratio conversion to create a compression number for png from the jpeg number. Also is this smart to link them or is it better to allow users to pick the compression for each individually. Thanks for any help.
I just spent a week bashing my head off the keyboard working on image handling code for my new project an just wanted to cheat on this an ask for help.
I don't know a lot about it, but I *think* that those numbers don't mean the same thing. The jpeg number is a quality factor because there is lossy compression being done. I *think* the 1-9 number for a png is the zlib compression level, which is a size/speed tradeoff and won't affect quality. If that's true, then maybe you don't even need to make that an option.
Action-N
01-26-2014, 08:06 PM
Just went an reread on it an yes your right, so they are not the same an shouldn't be connected. Reading the comments it says "-1" will set to the default compression of the server. Makes sense to do it that way. Plus I had it backwards, 9 was the most compressed an would have been reversed from the jpeg quality.
http://www.php.net/manual/en/function.imagepng.php
tbworld
01-26-2014, 08:20 PM
I am not a complete expert on this either, but I have written quite a few converters in my life.
@kh99 has it exactly right about the png deflate compression. In most cases these are back-end optimization settings and there is really no need to have your users set these values.
To sum up, on thumbnails... If I use image-magic/mogrify I use 85% on the thumbnail. GD2 I use 75% since there doesn't seem to be any great output clarity difference at 85%. if you detect retina devices and you have the ability to store separate thumbnails, then the numbers above my not apply, but I use the same numbers.
Portable devices we display a special resolution picture and no thumbnails, I played around for a long time on multiple devices and found that between 75% and 85% seemed optimum. Retina of course we send double the resolution. We use this lower sized picture as our thumbnails for desktop and let the user set the size of thumbnails. We have never found a need to alter the loss-less settings after our initial determination.
PS: Our pictures are typically technical so clarity is everything. Make sure you server does not try to re-deflate the images.
You might also want to look at 'jhead' and 'jpegtran' if your trying to add various user tools for your images.
Have fun! :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.