Lossless (mostly) JPEG Transformation Utilities

I recently discovered JPEG Clubs Suite of #software for mostly lossless JPEG processing software, (all free, gratis & open source), and couldn’t find it on the software list so thought I would chime in here:

  • jpegtran, (command line only but multi-platform), provides:

    • flip [horizontal|vertical] - Mirror image (left-right or top-bottom) lossless
    • rotate [90|180|270] - Rotate image (degrees clockwise) (mostly) lossless
    • flip [horizontal|vertical] Mirror image (left-right or top-bottom) lossless
    • transpose - Transpose image lossless
    • transverse - Transverse transpose image lossless
    • progressive - Create progressive JPEG file lossless?
    • optimize - Optimize Huffman table (smaller file, but slow compression) lossless
    • copy [none|comments|all] - remove or preserve extra markers
    • crop WxH+X+Y Crop to a rectangular subarea loses removed data
    • wipe WxH+X+Y Wipe (gray out) a rectangular subarea loses removed data
    • grayscale - Reduce to grayscale (omit color data)
    • scale - Scale output image by fraction M/N, eg, 1/8 (JPEG 9 Scaling)
    • several advanced options.
      Note that (mostly) lossless operations will have issues at the edges with some image sizes in these cases -trim will remove these edge pixels & -perfect will error if the operation cannot be done “perfectly”.
  • jpegcrop - Windows GUI version of the above.

  • djpeg & cjpeg - expand jpeg to pixel map and back.

What does mostly lossless mean?

I can add that tomorrow, or you can add it yourself if you know HTML and git: GitHub - pixlsus/website: The PIXLS.US website.

I think ‘mostly lossless’ means that the image needs to have dimensions of multiple of 8 (or 16 if subsampling is used) so that transformation can be applied to whole blocks without decoding the blocks. If tthe dimensions are not multiples of 8 then some blocks have to be decoded transformed and reencoded. That means the majority of the image uses lossless’ but border pixels may not be.

Hello everyone,

I am not a developer therefore I don’t know whether this might be useful but, as regards the utilities to lossless transform jpeg images, there is also this project:

“Lepton” has been released as open source by Dropbox:

1 Like

Crop origin must also occur on an exact multiple of 8 in both X, Y to avoid decoding/re-encoding.

Avoiding decoding/reencoding is IMHO mostly useful for performance reasons. JPEG degradation by re-encoding is much less than what people think, and stabilizes very quickly after a few decode/encode cycles (if you don’t change encoding parameters, decoding and re-encoding will eventually recreate the very same values).

As several of the others have replied Mostly Lossless for:

  • rotations is that if the dimensions of the image are not exact multiples of 16 then re-encoding will be needed around the edges which may introduce a degree of loss, (unless trim is used then the trimmed pixels are definitely lost).
  • Crop - the removed sections are definitely lost and if the positions are not all 16 multiples then re–encoding is required.

I’ve opened a pull request that adds JPEG Club and Lepton to the software page.

1 Like

Merged and published!

This is indeed cool. I had looked at this when they first announced it as a possibility for jpeg storage on this site (the main pixls.us site as well as possibly adding and pushing upstream for the forums). Just another thing I’d love to look at in more detail but lack the time… :wink:

Not quite the same thing but I have used jpegotim to cut down the filesize for facebook/web-based images with success. It has a lot of options but I haven’t tried that many to see if there are substantial wins in certain situations.