mozjpeg
mozjpeg copied to clipboard
hence preserving quality from .jpg input to output in cjpeg
Already for some time I use the new cjpeg but nowhere hadn't seen such an option. Normally, you need to choose a quality level or cjpeg chooses the value of 75.
Preserving quality factor from jpg source. example:
1. ffmpeg.exe -i file.png -c:v mjpeg -q:v 31 -pix_fmt yuvj420p out.jpg
(This creates a jpg file with unusual quantization tables.)
2. cjpeg -quality copy out.jpg > cjpegout.jpg
cjpeg reads qtables from the file, saves in the cache, and executes something like this:
cjpeg -qtables <cache> -qslots 0 out.jpg > cjpegout.jpg
DCTune for example, uses a separate quantization tables for each component, so we have to be careful with -qtables and -qslots.
Files saved in this way using mozjpeg (when I set manually -qtables) look almost identical to the source, and are a bit smaller.
In addition to the option described above You should introduce -copy none
(in cjpeg) so that I could stop using jpegtran ;)
I am not understanding why you would want to reencode the file with the same quant table instead of using jpegtran to optimize it.