Skip to content

WebP animations#25205

Merged
vadz merged 14 commits intowxWidgets:masterfrom
MaartenBent:webp
May 11, 2025
Merged

WebP animations#25205
vadz merged 14 commits intowxWidgets:masterfrom
MaartenBent:webp

Conversation

@MaartenBent
Copy link
Contributor

This extends #24479 by addressing some of the remarks made there, adding libwebp as a built-in submodule, and adding WebP animation support.
Also see #23489

webp.animation.mp4

I think it is mostly finished. Except for updating all the build files (only CMake is up-to-date currently). And documentation. And addressing some more remarks from the linked PR. And maybe adding support for saving WebP animations.

Copy link
Contributor

@PBfordev PBfordev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Maarten for the thankless tasks of finishing the PR.

Aside to specific nitpicks, it seems there are no checks for failed memory allocations (nor errors when reading from streams)? I am not sure what is wxWidgets policy for checking out-of-memory errors, in places with large allocations in particular...

Copy link
Contributor

@vadz vadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this!

I don't see any big problems, but there are, as you can see, quite a few small remarks (some of which I had already left in the original PR, but completely forgot about them...) — and I also agree with the comments already left by @PBfordev. I think I can count on you dealing with them when you have time but if you'd like any help with it (or disagree with any of them), please let me know.

FWIW I don't think it's critical to have this in 3.3.0, as it's a pure addition, we could add it in 3.3.1 too, but it would be nice to have it there, of course.

Thanks again!

@MaartenBent
Copy link
Contributor Author

Thanks @PBfordev and @vadz for the reviews. I'll address all the issues. But if 3.3.0-RC is planned for this month it'll probably not make it.

The only thing I would probably need help with (if we want this), is adding support to build the built-in version with configure. Similar to how it builds libtiff.

Copy link
Contributor Author

@MaartenBent MaartenBent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I addressed all of the review comments.

Questions:

  • Should I rename wxWEBPHandler to wxWebPHandler? All image handlers have capitalized names, but all WebP classes don't.
  • Where should the submodule go? src/webp or 3rdparty/webp?
  • I added wxBITMAP_TYPE_WEBP_RESOURCE because all formats have this. Is this fine?

Some things that I won't be adding (unless absolutely required):

  • Saving animated webp
  • Using built-in webp from configure (or msvs projects)

.gitmodules Outdated
branch = wx
[submodule "src/webp"]
path = src/webp
url = https://github.com/webmproject/libwebp.git
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you could make that would be great.

@vadz
Copy link
Contributor

vadz commented Apr 5, 2025

I think I addressed all of the review comments.

Thanks a lot!

Questions:

* Should I rename `wxWEBPHandler` to `wxWebPHandler`? All image handlers have capitalized names, but all WebP classes don't.

I guess we should keep this name for consistency, even although I find wxWebPHandler more readable too.

* Where should the submodule go? `src/webp` or `3rdparty/webp`?

I don't have strong preferences here, but I prefer 3rdparty.

* I added `wxBITMAP_TYPE_WEBP_RESOURCE` because all formats have this. Is this fine?

Hmm, this is not going to be implemented anywhere is it?

Copy link
Contributor

@vadz vadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot once again!

This globally looks good to merge to me. Ideal would probably be to build libwebp when using MSVS, just as we do with the other libraries, but this is not a hard requirement, whoever is interested in using it can always implement this later.

Copy link
Contributor Author

@MaartenBent MaartenBent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have strong preferences here, but I prefer 3rdparty.

I'll use this location then, once the fork is created.

Hmm, this is not going to be implemented anywhere is it?

No. I just copy-paste all the wxBITMAP_TYPE_GIF/wxBITMAP_TYPE_GIF_RESOURCE and added the same for WebP.
wxBITMAP_TYPE_GIF_RESOURCE also doesn't have any use.

Ideal would probably be to build libwebp when using MSVS, just as we do with the other libraries, but this is not a hard requirement, whoever is interested in using it can always implement this later

Yes, I can try to add it after this PR. Adding the files shouldn't be too difficult. Usually it us dealing with the generated config.h file.

@MaartenBent
Copy link
Contributor Author

I removed the libwebp msvc project, I'll add it to #25339 instead.

I moved the submodule to 3rdparty/libwebp and cleaned up all the commits. Only remaining change is using the correct submodule remote.
For that, the wx branch should point to tag v1.5.0, and I'll add a PR with some minimal changes wxWidgets/libwebp@eb311fd

@vadz
Copy link
Contributor

vadz commented Apr 27, 2025

I've reset wx branch now (by deleting the old one and recreating it in the right place, hopefully this didn't break anything).

hoehermann and others added 11 commits May 10, 2025 17:18
WebP sub-project searches for OpenGL, and sets the OpenGL variables to NOT_FOUND.
Make sure all OpenGL variables are updated when OpenGL dependency is set manually.
Add function to get the WebP library version.

Add LoadAnimation function to get all frame images, background colour and duration.

Use WebPAnimDecoder to decode frames other than the default (-1) frame.
This ensures all returned frames will have the same image size.
WebPDemuxGetFrame can return frames smaller than the full image size, but there is no way to get the offset of the frame.

Reduce code duplication when creating rgba image.

Add enum to store image format (undefined/mixed, lossy or lossless).
Add lossless and lossy quality options to wxImage for saving WebP.

Add wxBITMAP_TYPE_WEBP_RESOURCE because all other image handlers have this too.
Improve high-dpi support.
Run upmake, bakefile_gen, makeprojects.py, update-setup-h, autogen.
@MaartenBent MaartenBent marked this pull request as ready for review May 10, 2025 17:36
@MaartenBent
Copy link
Contributor Author

@vadz this and #25339 are now ready.

The last commit (Make wxImage::SetDataRGBA argument const) is not in the other PR, so I propose to merge this PR first and then #25339 (instead of only #25339).

@vadz
Copy link
Contributor

vadz commented May 11, 2025

Thanks a lot once again for all your work! I didn't realize configure was modified in the other PR too, so I've slightly changed it by adding commits here and so got conflicts when merging the other one later, but hopefully I didn't break anything resolving it.

In any case, I'm merging both PRs now.

@vadz vadz merged commit 5dd6290 into wxWidgets:master May 11, 2025
41 checks passed
vadz added a commit that referenced this pull request May 11, 2025
Add support for WebP image format, including animations.

See #24479, #25205.
@MaartenBent MaartenBent deleted the webp branch November 16, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants