Page MenuHome

ImBuf: Add support for WebP image format
Needs ReviewPublic

Authored by mathieu menuet (bliblubli) on Oct 31 2015, 4:52 PM.



Self-descriptive title actually.

Currently only support single image frames, no animation possible.

If quality slider is set to 100 then lossless compression will be used,
otherwise lossy compression is used.

Gives about 35% of file save when re-saving splash screens with lossless
Also saves much faster, up to 15x faster than PNG with a better compression ratio as a plus.

Known TODOs:

  • Single channel (BW) output support

Diff Detail

rB Blender
Build Status
Buildable 261
Build 261: arc lint + arc unit

Event Timeline

Sergey Sharybin (sergey) retitled this revision from to ImBuf: Add support for WebP image format.
Sergey Sharybin (sergey) updated this object.

Nice to see some alternatives to the nearly retired jpeg :) While at it, there is another really good opensource format called BPG:
It's better than WebP : . If we are goind to add a format for the coming years, better take the most efficient ones. Of course, having both would also be nice.
Good patch anyway.

Oh and it supports 14bit/channel, alpha channel, lossless compression, exif data and more:
Can be hardware accelerated on most computers as it uses H265 compression which has great support (unlike webM/webP)

Nice work.


This seems a rather unlikely location


is this the normal way to encode "lossless" ?. seems at least in other image formats you can do lossy at 100% quality.

It seems an acceptable way to encode 'lossless' and lossy at 100% quality.


seems to be a whitespace issue here ?

Oh and it supports 14bit/channel, alpha channel, lossless compression, exif data and more:
Can be hardware accelerated on most computers as it uses H265 compression which has great support (unlike webM/webP)

Please so not use patch review system as a feature request ticket system in the future, it is not intended or suitable for that kind of stuff.
We are well aware of the bpg format and its strengths ( good results, possible to leverage existing hardware decoders/encoders ) and weaknesses ( the library / implementation is not mature, possible patent minefield, etc)
This is about WebP but more importantly about the quality of the actual patch that integrates it.

BPG is rather messy library which relies on FFmpeg headers and can't be compiled on my laptop with some weirdo error messages. And it's not in any of the distros even.

While it seems interesting format, for until it's more widely distributed and made into an easier to compiled and use library i don't really consider it's priority to work on.


You're right, will fix


Not really. Sure enough it's good to encode lossy at 100% but then you'll need to add a button to do lossless compression, disable quality slider if that button is enabled and so on..

So question is whether we really want to go into that interface decision mess?


Guess so.

Sergey Sharybin (sergey) edited edge metadata.

Updates for Martijn's review.

Campbell Barton (campbellbarton) edited edge metadata.

Main issue afaics is webp doesn't seem all that popular, (similar to jpeg2000)
and other image formats are being developed which are significantly better (even if BPG isn't in a usable state at this moment).

On the other hand the webp library makes it very simple for us to support. So theres no big drawbacks besides having to support another dependency.

Patch seems fine, so only noting some very minor things.


Not a big deal, but this could be split off into a different commit.


prefer no parens around return values.

This revision is now accepted and ready to land.Dec 9 2015, 1:43 PM

First tests show actually pretty good results! For lossless compression with transparency (conversion of png images), I get better compression rations with WebP as with BPG. For lossy compression, there is still a clear advantage over jpg. In some cases, even with lossy compression, WebP did better than BPG. So it's a good addition!

This patch applied to latest master gives corrupted images if used in RGB. RGBA works like a charm.

on latest master, this patch still works with RGBA, but when used as a texture, it's completely purple in rendered viewmode in cycles but will display correctly in GLSL (RGB with and without transparency).
Same image saved as PNG will render correctly both in GLSL and in cycles.
So it seems some channels are not properly handled.

Still really good saving in space and in saving time (a Full HD PNG with transparency takes 1.5 second to be compressed, the same image with WebP takes 0.1 seconds = 15x faster in this test case while being 30% smaller)

This revision now requires review to proceed.Aug 11 2016, 6:12 AM

updating the patch to correct above mentioned problems and make it to apply on master.

mathieu menuet (bliblubli) updated this object.
mathieu menuet (bliblubli) removed rB Blender as the repository for this revision.

added missing bits and updated to master.

  • Move webp library discovery to platform specific modules.

@Sergey Sharybin (sergey) / @Martijn Berger (juicyfruit) i've been asked to land this one (which is fine, easy work), however given the review process has been kinda stale on this one, I'd like you to take a look and mark it as accepted (or rejected and request changes) before it moves forward.

There are couple of tweaks to be done here and there in the code, and AFAIR BW output is not solved yet (i don't remember fixing it anyway). Also guess biggest PITA would be to make build env adjustments because we'll need WebP libraries.

Other than that have no feedback here.

WebP is more widely used nowadays (and asked for, see Can we revisit this patch and include it in Blender?

WEBP is indeed more used nowadays than it was before. The most commonly used web browsers and graphics softwares already support this file type. It would be convenient if Blender could too.
I also hope that this patch could soon be reviewed. This could help make this great image file type more known/used.

It would be really great to see this feature supported! Especially useful for creating assets for Verge3D and other WebGL frameworks.