mozjpeg icon indicating copy to clipboard operation
mozjpeg copied to clipboard

How can you retrieve the quality value you specify when you run cjpeg on a file and you want it from what you got?

Open FredWahl opened this issue 1 year ago • 1 comments

I have jpg files and I want to compress some of them if they are large enough and they haven’t already been compressed by tools like cjpeg or jpegmini. It makes no sense to compress a file that has rhe same quality or lower than what I specify when I run cjpeg. So i need some tool that gives me this value. Imagemagick does return a quality value which turns out to be something called ”compression quality” which i think is something different. When I run this on my original file, I got 93 and when I did the same on my compressed file, it returned 0 which isn’t very helpful. What I want is sometimes that returns the same value that i used in cjpeg.

FredWahl avatar Jun 09 '24 18:06 FredWahl

the quality value used for compression is not stored in the jpeg file -- it's not really needed for image reconstruction. if you have control over the initial compression, you can save that value as a comment in the jpeg file and then read it back. otherwise, there's no way to say exactly what -q value was used. also while -q is important, there are other factors that may significantly affect the quality so relying on -q exclusively may be misleading. you can get an estimate of the quality by checking DCT block statistics

vkolesn avatar Jul 08 '24 11:07 vkolesn