Page 1 of 1

Check if an image is already optimized for the web

Posted: 2013-07-08T09:30:51-07:00
by tirengarfio
Hi,

I have found this tool that optimizes images for the web. What is surprising for me is that it only optimizes the uploaded image if it is possible, I mean, if it considers that the image is already optimized for the web it says "No savings".

My question: before running something like "convert -quality 80", is there any way (using imagemagick or any other tool in linux) to ckeck if an image is already optimized for the web? In that case I would not run "convert -quality 80".

Javi

Re: Check if an image is already optimized for the web

Posted: 2013-07-08T09:38:37-07:00
by Bonzo
You would need to decide what you limitations want e.g. file size, image size etc. and Imagemagick could get the information from the image and compare them to the limits you set.

Re: Check if an image is already optimized for the web

Posted: 2013-07-08T09:58:21-07:00
by tirengarfio
Thanks, but I don't have to give the data you mention (file size, image size..) to the tool I mentioned. The tool I'm talking about keeps the image size. How to know those limitations you are talking about? That tool puts the limitations by itself.

Re: Check if an image is already optimized for the web

Posted: 2013-07-08T10:33:23-07:00
by Bonzo
Thanks, but I don't have to give the data you mention (file size, image size..) to the tool I mentioned.
From you post I assumed you were writing your own code and you would then put limits into variables in your code which the code would check against.
If the image dimensions were larger than your limits it would resize the image and if not it would leave it alone.
That is how that code would have been written - somebody would have decided what the limits were.

If you were just resizing you could use the built in resize options. Check the geometry link in the resize section to see what they are.

Re: Check if an image is already optimized for the web

Posted: 2013-07-08T10:35:51-07:00
by fmw42
What do you mean by optimize for the web? That usually means you are writing a JPG output and want the quality and compression set to some minimum.

Re: Check if an image is already optimized for the web

Posted: 2013-07-08T11:12:01-07:00
by glennrp
From the descriptions of the tool at their web site and other sites, it appears to be roughly equivalent to "convert -strip" for JPEGs. For PNGs it also applies pngcrush or similar. I don't see the source for it so can't tell exactly what it does.

Re: Check if an image is already optimized for the web

Posted: 2013-07-09T04:12:26-07:00
by tirengarfio
Thanks for your answers, I have found here a list of the tools that website uses:

http://developer.yahoo.com/yslow/smushi ... _crushtool

http://developer.yahoo.com/performance/ ... opt_images

I don't understand exactly the meaning of "..and try progressive JPEGs.".

Re: Check if an image is already optimized for the web

Posted: 2013-07-09T08:25:44-07:00
by GreenKoopa
To reduce the size of a jpeg without modifying the image data: First, toss out the non-image data (metadata) in the file. The thumbnail, camera settings, comment, etc.
Second, redo the lossless compression step. Baseline (Huffman) encoding can be optimized, but often isn't because it is more processor intensive. Especially historically or in cameras. Progressive encoding splits the image into multiple passes of detail. There are many different splits possible, and each may increase or decrease file size. This advanced feature is more widely supported than it used to be. Arithmetic coding can reduce a jpeg further, but is not widely supported (old patents). Further reduction can be achieved by redoing the lossy compression steps.

"progressing JPEGs" - Are you old enough to remember dial-up? Images were new to the internet and sooo slooow! Maybe they will make a comeback with the high-resolution screens and low bandwidth of mobile devices?

Baseline loading looks like:
Image
Progressive loading looks like:
Image
These images are from this article, which mentions your tool.