Should jpegtran remove more bytes than mogrify strip?

2

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?

robjmills

Posted 2011-08-23T14:28:02.233

Reputation: 155

Answers

3

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.

DerfK

Posted 2011-08-23T14:28:02.233

Reputation: 917

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 – robjmills – 2011-08-23T15:33:09.210

1

confirmed here http://www.imagemagick.org/script/formats.php "By default we compute optimal Huffman coding tables"

– robjmills – 2011-08-24T10:29:12.237