tjko / jpegoptim

jpegoptim - utility to optimize/compress JPEG files
http://www.iki.fi/tjko/projects.html
GNU General Public License v3.0
1.56k stars 116 forks source link

-S100 but result is 200k #75

Closed guettli closed 2 years ago

guettli commented 4 years ago
jpegoptim --stdout -S100k orig.jpg > result-jpegoptim.jpg 
===> ls -lh result-jpegoptim.jpg
-rw-r--r-- 1 guettli guettli 201K Mai 17 09:31 result-jpegoptim.jpg
===> jpegoptim --version
jpegoptim v1.4.4  x86_64-pc-linux-gnu
Copyright (c) 1996-2016, Timo Kokkonen

libjpeg version: 8d  15-Jan-2012
Copyright (C) 1991-2017 The libjpeg-turbo Project and many others

orig

result-jpegoptim

zvezdochiot commented 4 years ago
$ jpegquality result-jpegoptim.jpg

jpegquality version 1.2

#File: result-jpegoptim.jpg
Quantization table
  Precision=0; Table index=0 (luminance)
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
  Estimated quality level = -155.00%
  Quality too low; estimate may be incorrect.
Quantization table
  Precision=0; Table index=1 (chrominance)
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
     255 255 255 255 255 255 255 255
  Estimated quality level = -155.00%
  Quality too low; estimate may be incorrect.
Average quality: -155.00% (-154%:Poor)

:information_source: 255 - this is the limit.

guettli commented 4 years ago

@zvezdochiot please elaborate. What do you want to tell me with your comment?

zvezdochiot commented 4 years ago

Hi @guettli .

:information_source: The value 255 is the maximum in the quantization tables (see above). Quantization tables are a jpeg filtering mechanism. It is impossible to get more filtering with jpeg, and the file will not become smaller than this level.

guettli commented 4 years ago

My goal is the reduce the file size while keeping the image nice for the human eye.

I found a solution and published it here: https://github.com/guettli/cheat-sheet/blob/master/README.md#reducing-image-size

convert image.jpg -resize '1000x>' -define jpeg:extent=100KB result.jpg

This reduced the resolution before reducing the jpg-size. The result is better than with jpegoptim.