sigal
sigal copied to clipboard
Consider next gen image formats?
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.
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
:
https://github.com/saimn/sigal/blob/7ba5f7b441a709dc7418807c0a4c46b78b6b2872/sigal/templates/sigal.conf.py#L49-L60
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).
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 |
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.
Excellent, thanks !
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 ?
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.
Good point :+1:
Shall enabling the WebP make uses of the HTML5 <picture>
element (with JPEG fallback) to get the best support?
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.
Hi, I'm wondering if there's any news on avif support?