GoogleChromeLabs / squoosh

Make images smaller using best-in-class codecs, right in the browser.
https://squoosh.app
Apache License 2.0
21.82k stars 1.53k forks source link

Support Progressive AVIF #1377

Open tongyuantongyu opened 1 year ago

tongyuantongyu commented 1 year ago

Is your feature request related to a problem? Please describe. It's widely considered a weakness that AVIF does not support progressive rendering. But actually, AVIF does support it. Try the following image, which will render progressively on Chrome, if you are on a slow connection.

progressive-photo.avif

Describe the solution you'd like The support for encoding progressive image is in libavif for quite a while. Squoosh can leverage that to provide options to produce progressive AVIF images.

Does other service/app have this feature? libavif API support this feature. I have an open PR to support progressive encoding from avifenc command line: https://github.com/AOMediaCodec/libavif/pull/1450. With that PR the image above can be encoded with the following command:

convert photo.jpg -resize 2% -blur 0x2 -resize 3872x2592! photo-blur.png
avifenc -s 3 -j 24 -y 420 -a denoise-noise-level=50 -a end-usage=cbr --sharpyuv --cicp 1/13/1 --layer 3 --ignore-exif \
 -q 50 --scaling-mode 1/4 photo-blur.png \
 -q 10 --scaling-mode 1/2 photo.jpg \
 -q 50 --scaling-mode 1 photo.jpg photo.avif

Additional context "Progressive" in AVIF works quite different from progressive in other formats. A better way is to think it as a video (or animation), but marked as display_next_frame_as_soon_as_possible and stop_at_last_frame. This also means: