Vampyre Imaging Library Forum

Imaging Category => Suggestions, Feature Requests, Contributions => Topic started by: Christian on 5 January 2020, 22:29:09

Title: WebP Image File Format
Post by: Christian on 5 January 2020, 22:29:09
Are there any plans to add support for the WebP Image File Format?

It seems as if this format is getting more and more important since it is increasingly used in websites.
Title: Re: WebP Image File Format
Post by: Galfar on 6 January 2020, 00:59:29
Yes, it is planned. Progress on Imaging is very slow but WebP is now one of the top priorities.

So far there is this contribution I received (attached, FPC only).
Title: Re: WebP Image File Format
Post by: Christian on 20 February 2020, 00:45:30
Great to hear that!

I will have a look at this contribution. Is it working for FPC or is it still in progress?

Please tell if you need some more help.
Title: Re: WebP Image File Format
Post by: Galfar on 21 February 2020, 12:15:31
I remember there were some linking errors but I haven't spent much time with it.
For a official WebP support in Imaging I'd go with using dynamic library.
Static linking with C object files (like here or Imaging's JPEG2000 and TIFF support) is nice that you get self-contained exe but it's a nightmare to test and maintain for all platforms.
Title: Re: WebP Image File Format
Post by: Christian on 27 February 2020, 04:32:03
Do you mean that you would need an external DLL file to work with WebP?

I think one of the main advantages of Imaging is that you do not need external files and you get only one exe file. That is also one of the main reasons speaking for your library. I hope you will not change that...
Title: Re: WebP Image File Format
Post by: Galfar on 27 February 2020, 13:49:46
I know, but with the very limited time available there's not much choice for these more complex image formats.
There used to be a way to embed DLL inside Windows EXE as a resource and use it directly from there, I'll see if it's still feasible with 64bits today. For library user that would be transparent like with C object files.
Title: Re: WebP Image File Format
Post by: Christian on 16 May 2020, 21:46:55
I see the time argument. Although, I would prefer waiting longer and going without the DLL solution.

There are so many libraries out there coming with DLLs and up to now Vampyre Imaging is the only with no need of a DLL so far as I know. It would be great if it stays so, also because of platform independence reasons (DLL is Windows only and any program I have written in Lazarus was compiling on Linux without any changes) and especially for little tools coming without an installer.

But of course, you are the developer, its your choice. I even cannot imagine how complex WebP is...
Title: Re: WebP Image File Format
Post by: Luca Olivetti on 15 June 2020, 16:03:39
Quote from: Galfar on  6 January 2020, 00:59:29Yes, it is planned. Progress on Imaging is very slow but WebP is now one of the top priorities.

So far there is this contribution I received (attached, FPC only).


I took this zip and added support for loading animated webp.
I only tested with fpc (win32 and linux 64).
Under linux I just link with the system (in my case kubuntu) provided library, under windows I used your version of libwebpwin32.a and I took libwebpdemux.a from google (version 0.6.1, since it's the same I have in kubuntu). I also changed the windows version to dynamically link msvcrt and kernel32.
Note that I also had to reverse the colors (WepPDecodeRGBAInto -> WebPDecodeBGRAInto) since the red and blue channels were swapped.

I'm attaching the patch to this message.
Title: Re: WebP Image File Format
Post by: Luca Olivetti on 15 June 2020, 16:09:09
Quote from: Luca Olivetti on 15 June 2020, 16:03:39I'm attaching the patch to this message.

Here it is (I hope)