ideas icon indicating copy to clipboard operation
ideas copied to clipboard

WebP generation

Open S1SYPHOS opened this issue 6 years ago • 9 comments

Hello there, I'd love to see WebP generation as part of Kirby's core; maybe alongside PNG / JPG generation in media folder?

WebP is a method of lossy and lossless compression that can be used on a large variety of photographic, translucent and graphical images found on the web. The degree of lossy compression is adjustable so a user can choose the trade-off between file size and image quality. WebP typically achieves an average of 30% more compression than JPEG and JPEG 2000, without loss of image quality (see Comparative Study).

Google Developers

Current browser support for WebP images is somewhat decent (Chrome, Opera & most mobile browsers, and since 01/2019: Firefox!), globally just about 80%.

For GD / Imagick, there's a PHP lib which I co-authored a while ago that might be a good starting point: https://github.com/rosell-dk/webp-convert

Anyway, thanks for listening .. and making Kirby.

S1SYPHOS avatar Mar 19 '19 23:03 S1SYPHOS

Our GD lib implementation already supports webp as a source. You can toss webp images in your content folder and the thumbnails should be created correctly. I believe imagemagick can handle them as well, but I haven't tested that.

It would indeed be cool though to offer a conversion option for thumbs.

bastianallgeier avatar Mar 20 '19 14:03 bastianallgeier

@bastianallgeier it seems the webp mime is not part of the defaults for $page->images() collection. please make it a first class image citizen there as well.

bnomei avatar Mar 21 '19 07:03 bnomei

first class image citizen

I'm loving it :hamburger:

S1SYPHOS avatar Mar 21 '19 17:03 S1SYPHOS

Tl;dr: Progressive jpegs are almost always better then webp, even though they are "larger".

The longer explication why: I went to perfnow()-conference, and saw a really interesting talk from Kornel Lesiński about "perceived performance" with images. Full video here: https://www.youtube.com/watch?v=jTXhYj2aCDU

bvdputte avatar Apr 15 '19 12:04 bvdputte

Thanks for the video! Bit off-topic, but I especially like the interviewer at the end, nodding constantly like one of these nodding head figurines.

Anyhow, I'm still intrigued by offering WebP conversion for thumbnails, though not being enabled by default. Also, it seems to me that Chrome ('Hello Google') loads WebP progressively by default, and since most people these days are using it as default browser (and will continue to do so, I'm afraid), this is still a viable option - Google will improve WebP along with Chrome for better (perceived) performance. This alliance is what makes it an even more interesting choice!

S1SYPHOS avatar Apr 16 '19 08:04 S1SYPHOS

The problem is that Safari does not work with WebP at all, which puts alot of ios devices out of the picture. You still need a Jpeg fallback today.

However, i did just release a WebP plugin for K3 that converts uploaded files but keeps the source file ... https://github.com/HashandSalt/kirby3-webp

HashandSalt avatar Nov 04 '19 10:11 HashandSalt

The problem is that Safari does not work with WebP at all, which puts alot of ios devices out of the picture. You still need a Jpeg fallback today.

Apple has added support for WebP images in the upcoming versions of Safari that will ship with iOS 14 & macOS 11.

lastloop avatar Jun 25 '20 08:06 lastloop

WebP would only ever need to be created alongside normal thumbnails IMHO, and .htaccess taking over the rest, that way you get the fallback AND serve WebP to suitable browsers. What do you think, @HashandSalt? Then again, you'd loose ppl serving full images straight from the content folder ..

S1SYPHOS avatar Jul 28 '20 10:07 S1SYPHOS

Would be great, if the core generates webp by default.

findthebug avatar Jan 04 '21 14:01 findthebug