Check if an image is already optimized for the web

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tirengarfio
Posts: 7
Joined: 2013-05-31T05:10:43-07:00
Authentication code: 6789

Check if an image is already optimized for the web

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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.
tirengarfio
Posts: 7
Joined: 2013-05-31T05:10:43-07:00
Authentication code: 6789

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

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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.
Last edited by Bonzo on 2013-07-08T10:35:52-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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.
tirengarfio
Posts: 7
Joined: 2013-05-31T05:10:43-07:00
Authentication code: 6789

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

Post 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.".
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

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

Post 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.
Post Reply