Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider next gen image formats? #429

Open
Mousketeer opened this issue May 3, 2021 · 10 comments
Open

Consider next gen image formats? #429

Mousketeer opened this issue May 3, 2021 · 10 comments

Comments

@Mousketeer
Copy link

I speak from great ignorance, but wouldn't it be interesting to support something more modern than jpeg - after all a 1992 format?

Newer formats offer far better compression ratios (meaning smaller and faster galleries at better quality) higher colour depth and space and a lossless option (not sure if that's a valid point in Sigal's context, but still).
Drawbacks include massively increased encoding time and slightly more complicated system requirements.

  • WebP seems universally supported and a safe stepping stone.
  • From the contenders for The Next Big Standard my pick is AVIF.
    • From the encoding side there is a Pillow plugin pending official merger.
    • Client side the latest chrome and firefox support it natively. There is avif.js that transparently (as in: clientside javascript decodes the image and paints it on the screen) brings support to 95% of the browser market. The fallback/upgrade mechanism for the current jpegs is elegant.

I'm afraid I can only "help" and not "do", but I thought to get something rolling with this issue.

@saimn
Copy link
Owner

saimn commented May 4, 2021

Not sure about AVIF, which are the pros etc., but at least for webp, yes it would be great to support it. I think you can already try by adding the webp extension to img_extensions :

# Output format of images (default: None, i.e. use input format)
# img_format = "JPEG"
# Show a map of the images where possible?
# This option only has an effect on the galleria theme for the while.
# The leaflet_provider setting allow to customize the tile provider (see
# https://github.com/leaflet-extras/leaflet-providers#providers)
# show_map = False
# leaflet_provider = 'OpenStreetMap.Mapnik'
# File extensions that should be treated as images
# img_extensions = ['.jpg', '.jpeg', '.png', '.gif']

If you want to help with things other than code, a few more things would be useful:

  • provide 1 or 2 test images in webp format, compatible with sigal's license
  • find since which version of Pillow webp is supported (I guess it's not recent but a check can be useful)

Also it seems that support in Safari is very recent (macOS 11).

@Mousketeer
Copy link
Author

Adding webp to img_extensions causes images to be generated flawlessly - Wonderful! There just isn't any fallback.

I've made a super bland nonsense image and it's herewith in the public domain: one and two (also in a gallery of course)

Different qualities yield very different file sizes (all available in the gallery above). But as mentioned file size isn't the only advantage.

Level First image Second image
lossy5 524K 124K
lossy8 600K 136K
lossy10 648K 144K
lossy60 1.9M 316K
lossy70 2.3M 364K
lossy75 2.5M 392K
lossy80 3.2M 504K
lossy85 4.4M 668K
lossy90 5.7M 1.1M
lossy95 30M 19M
lossless 30M 19M

@Mousketeer
Copy link
Author

Based on the Changes file in the Pillow repository, the first mention of webp is in 2.1.0 (2013-07-02) with metadata support in 2.2.0, and I see no bugs beyond 5.1.0.
As far as I can see the current Sigal requirement for Pillow7 doesn't need to change to support webp.

@saimn
Copy link
Owner

saimn commented May 5, 2021

Excellent, thanks !

@saimn saimn mentioned this issue Jun 27, 2021
@saimn
Copy link
Owner

saimn commented Jun 27, 2021

webp is done with #433, thanks @Mousketeer for the test images. Maybe we can reconsider AVIF in the future when it is more widely supported ?

@saimn saimn closed this as completed Jun 27, 2021
@DuendeInexistente
Copy link

DuendeInexistente commented Jul 11, 2021

Webp isn't quite there yet, it's an invalid setting for img_format .

Bit of an addenum but it's important for the format, would be good to also get a setting to make webp lossless if it's picked for that.

And something else besides that: webp supports animation too. I don't know what proccesor's used by this, but if it supports webp animation it'd be a mayor quality boost, even set to lossless webp makes way smaller files.

@saimn
Copy link
Owner

saimn commented Jul 13, 2021

Good point 👍

@saimn saimn reopened this Jul 13, 2021
@romain-dartigues
Copy link

Shall enabling the WebP make uses of the HTML5 <picture> element (with JPEG fallback) to get the best support?

@saimn
Copy link
Owner

saimn commented Sep 1, 2021

I think WebP is also supported by <img> ? <picture> would be interesting if sigal could generate multiple sizes / formats but that's not the case currently.

@reagle
Copy link

reagle commented Aug 4, 2023

Hi, I'm wondering if there's any news on avif support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants