Page 1 of 1

WebP Imageplugin

Posted: Sun Sep 02, 2012 11:47 pm
by Rescator
https://developers.google.com/speed/webp/

v0.2.0 seems very mature, and is the one used in Chrome AFAIK.

A image plugin is kind of a must for PureBasic since trying to use libwebp.lib with PB is kinda cumbersome as the image is upside down and a raw bitmap, so you have to use startdrawing() and imageoutput() and drawingbuffer() and a loop to flip the image vertically, while ideally the webp image should just be decoded and written directly to a image bitmap buffer in the right order.

WebP (Lossless) has aprox. 25% better compression than PNG.
WebP (Lossy) has aprox. 25% better compression than JPG.
WebP lossless with alpha takes up around the same size as a PNG without alpha.
WebP can have a lossy image but lossless alpha.
WebP can also have lossy alpha.
Both lossy and lossless have either quality or compression settings.

If a WebP plugin is made loading and saving would be like this:
LoadImage() is the same as the others.


SaveImage(#Image, Filename$ [, ImagePlugin [, Flags [, Depth]]]) ;this one is a little more complex.

New constant #PB_ImagePlugin_WEBP (or #PB_ImagePlugin_WebP ?)

Flags: Quality, a value from 0 to 100, with 100 being the same as WebP lossless mode, 100 to 106 being lossless compression speed 0 to 6 with 100 being fastest and 106 slowest.
Depth: optional, 8, 24, 32 (1 and 4 as well?)

Why this way? Because by the looks of it the webp example tools either use floating point from 0.0 to 1.0 or from 0 to 100 for lossy quality. And Lossless WebP is a different mode and has 7 different compression speeds (and thus compression rates, but they all are lossless) ranging 0 to 6. And this avoids having to change the function params.

And is WebP worth the effort? Absolutely. First of all it's under a similar license to the xml library. (basically it's the BSD license) so it ca be used in closed source/proprietary/commercial projects.

And more importantly the size reduction. A PNG image here that was 219KB (after optimized using 3 different PNG optimizers) became only 167KB with WebP lossless mode, that's around 30% size reduction.
See http://en.wikipedia.org/wiki/WebP#Support for a growing list of what supports WebP. Also lates Firefox releases also support WebP, so the list on wikipedia is a little outdated.

For WebP lossless decoding speed (which is as important as the compression IMO) https://developers.google.com/speed/web ... lpha_study (look at Table 3. Average decoding time).


OK! I'll stop gushing and shut up now... But WebP has really impressed me.

Re: WebP Imageplugin

Posted: Thu Mar 12, 2020 6:41 pm
by Pforzheimer
+1

EncodeImage() would be most important for me right now.

UseWebPImageDecoder(), UseWebPImageEncoder(), SaveImage(), LoadImage()

Nice Greetings
and thank you for the nice work in the last years :D[/b]

Re: WebP Imageplugin

Posted: Thu Mar 12, 2020 7:28 pm
by Mijikai
Seems that their (especially lossy) compression is worse than anything else quality wise.
I dont see any good reason why this would be a preferable or needed option.
Further the bad quality should not be a suprise since google uses a videocodec on still images!

Re: WebP Imageplugin

Posted: Wed Aug 19, 2020 8:33 pm
by Seymour Clufley
As the WebP format is now viewable on 80% of web browsers, it would seem like a format worth adding to PB.

Re: WebP Imageplugin

Posted: Tue Sep 15, 2020 9:32 am
by BarryG
+1, and for HEIF if possible because it's very common now for online images.