Thursday, January 13, 2005


Independent JPEG Group offers lossless JPEG optimization

My previous post talked about some new software which can compress JPEGs losslessly by up to 30% when adding them to an archive. This got me thinking about how this might be achieved, and the obvious place to experiment seemed to be the widely used Independent JPEG Group's jpeg library.

Looking through their offering, I noticed the jpegtran program, which is able to perform lossless transforms on JPEG files - such as rotation without performing the decompression and recompression which most other image processing apps do to do this.

I also found that this program offers an -optimize parameter, which the help says performs "Optimize Huffman table (smaller file, but slow compression)". The relevant command line is "jpegtran -optimize -copy all in.jpg out.jpg". Running this on a number of files showed that even this simple operation makes a big difference to the file size:
I checked that the images were identical by loading both the before and after images into an image processing application, and saving them as a 24bpp TIFF. The images from the original and the better compressed images were byte for byte identical. The "-copy all" parameter ensured that all extra information, such as the EXIF info and comment info was also retained by the operation.

Note that I am still ending up with a perfectly valid jpg format file - loadable in any image processing package. This is not what Stuffit are doing - they are trying to introduce a new image format that is incompatible with existing image processing programs.

It's certainly been an eye opener for me - I'll be reprocessing all the images on my website to take advantage of the better compression this simple operation gives me.

Comments: Post a Comment

Links to this post:

Create a Link

<< Home