google / guetzli

Perceptual JPEG encoder
Apache License 2.0
12.9k stars 976 forks source link

jpg advantage and png disadvantaged? #116

Open vdingtian opened 7 years ago

vdingtian commented 7 years ago

i,try some test,comare with imagemagick. use guetzli compress jpg better than imagemagick,bug png is not。

better means Similar clarity , file size Smaller.

why?

robryk commented 7 years ago

Thanks for trying out Guetzli. Could you post the files you've tried and the sequences of commands you've used?

vdingtian commented 7 years ago

/bin/Release/guetzli --quality 84 source.png compress_by_guetzli.png /bin/Release/guetzli --quality 84 source.png compress_by_guetzli.jpg

magick -quality 84 source.png compress_by_magick.png magick -quality 84 source.png compress_by_magick.jpg

source.png: source

compress_by_guetzli.jpg compress_by_guetzli

compress_by_guetzli.png compress_by_guetzli

compress_by_magick.jpg compress_by_magick

compress_by_magick.png compress_by_magick

robryk commented 7 years ago

Guetzli doesn't produce png files. The compress_by_guetzli.png is actually a JPEG file and is identical to compress_by_guetzli.jpg

It's true that the png files are smaller than the jpg files produced here. This appears to be an image where png format works very well.

compress_by_gutezli.jpg is larger than compress_by_magick.jpg, but is of significantly higher quality (e.g. compress_by_magick.jpg has strong artifacts on the sides of the "1" in the label on the left). The quality parameter comes from a made-up scale. Guetzli's quality is designed to approximate the meaning of JPEG quality in YUV444 mode. The ImageMagick image was generated in YUV420 mode (which reduces filesize and quality). If you encode using ImageMagick in YUV444 mode with the same quality parameter:

convert source.png -sampling-factor 4:4:4 -quality 84 magick_444.jpg

you get an image that's of similar quality to compress_by_guetzli.jpg, but larger.

DeeDeeG commented 7 years ago

I did get something similar to what this issue's title suggests.

So I get smaller output with finer details if I give a JPEG in than if I give a similar-looking PNG in.

PNG in: city-photo-sharper-1600.png

JPEG in: city-photo-sharper-1600-gimp-100.jpg

(I think anything that produces an optimized DCT before using Guetzli, but otherwise leaves visible quality alone, improves Guetzli's output. So, running any jpeg encoder with DCT optimization turned on, and output at quality 100, should reduce the file size Guetzli produces by some amount. It's not a lot, but it can make a difference, especially for small files.)