saimn / sigal

yet another simple static gallery generator
http://sigal.saimon.org/
MIT License
883 stars 169 forks source link

Consider next gen image formats? #429

Open Mousketeer opened 3 years ago

Mousketeer commented 3 years ago

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.

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

saimn commented 3 years ago

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:

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

Mousketeer commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Excellent, thanks !

saimn commented 3 years ago

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 ?

DuendeInexistente commented 3 years ago

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 commented 3 years ago

Good point :+1:

romain-dartigues commented 3 years ago

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

saimn commented 3 years ago

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 commented 1 year ago

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