简体   繁体   中英

jpegoptim vs jpegtran vs mozjpeg

I found two slightly conflicting blog posts on this matter, here I summarize:

Adding to confusion, this Reddit thread suggests that mozjpeg uses the same algorithm used in jpegcrush, and that jpegcrush is a wrapper for jpegtran... so we've come full circle? I can only assume that those Reddit comments are wrong, can anyone confirm that?

MozJPEG library uses one algorithm inspired by jpegcrush (optimized progressive scans), but technically it's a completely new implementation.

MozJPEG library is a drop-in replacement for the popular libjpeg, so almost every JPEG-related tool can be compiled in "regular" and "MozJPEG" flavors.

There exists a "regular" jpegtran and a MozJPEG version of jpegtran . That's the same program, but the MozJPEG version has different default settings and performs extra work to compress better.

Similarly, jpegoptim is usually built with stock libjpeg, but it's also possible to build it with MozJPEG's version of libjpeg (eg ImageOptim does it).


There are two ways to use MozJPEG:

  1. lossless (take an existing JPEG file and make it a bit smaller). That's what MozJPEG's jpegtran does.
  2. lossy (create a new JPEG file from uncompressed pixels, with higher quality/filesize ratio). That's what MozJPEG's cjpeg does, and other tools like jpegoptim can be made to do with MozJPEG.

Both modes of operation are slower than vanilla non-optimizing libjpeg. Lossless optimization does less work, but also achieves smaller gain.

More precise speed analysis is here: https://libjpeg-turbo.org/About/Mozjpeg

Note that "slow" here is relative. In absolute terms it compresses several megapixels per second, so it may be fast enough for most applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM