Encode and Decode using the libwebp library via WASM with animation support#14234
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
This comment was marked as outdated.
This comment was marked as outdated.
|
As to performance:
|
5ea980b to
1533025
Compare
f624c3b to
aa1fc0a
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates WebP image encoding and decoding from native Go libraries to a WASM-based implementation using libwebp, adding support for animated WebP images. The change removes the dependency on the "extended" build for WebP support, making it available in all builds.
Key changes:
- Replaces native WebP codec with WASM-based libwebp implementation
- Adds animation support for WebP images
- Removes extended build requirement for WebP functionality
Reviewed changes
Copilot reviewed 36 out of 57 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tpl/images/images.go | Updates image config decoding to use new codec interface |
| resources/resource_spec.go | Integrates WASM dispatchers and exposes Imaging field |
| resources/images/webp/webp.go | Removes old extended build WebP encoder |
| resources/images/webp/webp_notavailable.go | Removes old non-extended build WebP stub |
| resources/images/config.go | Updates WebP version and documentation |
| resources/images/imagetesting/testing.go | Refactors to use new codec with animation support |
| resources/images/images_golden_integration_test.go | Adds comprehensive WebP processing tests |
| resources/image_extended_test.go | Removes obsolete extended-only WebP test |
| resources/testdata/webp/* | Adds WebP test fixtures (binary files) |
| resources/images/testdata/images_golden/process/webp/* | Adds golden image test files (binary files) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces WebP image processing using a WebAssembly (WASM) module, replacing the previous cgo-based implementation. This change adds support for animated WebP images. The implementation involves a new RPC-like protocol over stdin/stdout to communicate between Go and the C code in the WASM module, handling both JSON metadata and binary image data.
The overall implementation is well-structured and impressive. I've found a couple of related issues regarding the conversion between animated image formats, which I've detailed in my comments. Specifically, the conversion from animated WebP to animated GIF is not correctly implemented, and the himage.ImageFrames interface needs to be improved to support this correctly.
17e54eb to
44693e2
Compare
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces WebP image processing support using a WebAssembly (WASM) module, replacing the previous CGo-based implementation. This is a significant improvement for portability. The changes include a new communication protocol between Go and the WASM module to handle binary data streams, new interfaces for animated images, and a centralization of image codec logic. The implementation is extensive and well-structured. I've found one critical issue in the C code of the WASM module that could lead to a crash. Other than that, the changes look solid.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-executed refactoring to handle WebP image processing using WebAssembly (WASM) instead of CGo. This change enables WebP support, including animations, across all Hugo versions, not just the extended one. The implementation includes a new WASM RPC communication layer that supports binary data streams, a generic image codec abstraction, and new interfaces for animated images. The changes are extensive and touch many parts of the codebase related to image processing and resource handling. I've found one critical issue related to goroutine variable capturing that needs to be addressed. Otherwise, the changes look solid and the addition of tests is commendable.
…upport Fixes gohugoio#10030 Fixes gohugoio#8500 Fixes gohugoio#12843 Fixes gohugoio#8879 Fixes gohugoio#12842

Fixes #10030
Fixes #8500
Fixes #12843
Fixes #8879
Fixes #12842
Some issues left TODO: