Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently using mogrify -strip image.jpg to remove unwanted bytes from images, it was suggested I could remove further data by using jpegran from libjpeg, something like:

jpegtran -copy none -optimize -outfile image.jpg image.jpg

The problem I'm having – if it even is a problem – is that jpegtran doesn't seem to actually do anything that mogrify isn't already doing. In all my testing the filesize just stays the same. If I remove the mogrify part of my code and replace with jpegtran then it seems to perform the same function.

For example:

  • image without compression: 300k
  • image with mogrify -strip + jpegtran: 272k
  • image with mogrify -strip only: 272k
  • image with jpegtran only: 272k

I was under the impression though that mogrify just removed image profiles/comments and that jpegtran did this as well as losslessly compressing the image to make it smaller. Am I missing something?

share|improve this question

migrated from serverfault.com Aug 23 '11 at 14:30

This question came from our site for system and network administrators.

up vote 3 down vote accepted

Wikipedia says that jpegtran "optimizes the Huffman coding layer", strips extra application specific data (what mogrify -strip does), and converts between progressive and non-progressive jpeg formats. It also has the ability to crop, rotate/flip, and convert to grayscale without decompressing and recompressing the image.

I presume that if the Huffman coding layer is already at it's optimum state, jpegtran can't do any better.

share|improve this answer
    
i would assume that too, but it seems unlikely given i've tried images from various sources (digital camera/iPhone/web) and found the results to be the same – seengee Aug 23 '11 at 15:33
1  
confirmed here imagemagick.org/script/formats.php "By default we compute optimal Huffman coding tables" – seengee Aug 24 '11 at 10:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .