GIF support#102
Closed
xfalcox wants to merge 3 commits into
Closed
Conversation
New decode-only package using giflib to decode GIF images to ImageData, following the same WASM + Emscripten pattern as existing codecs. Decodes the first frame of animated GIFs with transparency support. Compiled WASM is only ~21KB since giflib is lightweight. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- decodeAnimated(): returns array of {imageData, duration} for each frame
with proper disposal method handling (background restore, previous restore)
- isAnimated(): returns boolean indicating if GIF has multiple frames
- decode() still returns first frame as ImageData (unchanged)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Checks for GIF87a/GIF89a header and throws a clear error message when the file is not a valid GIF (e.g. a WebP with a .gif extension). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
|
Thanks @xfalcox. This is awesome. If it's ok, I'll take a look at these PRs over the weekend and get back to you with any comments 🙏 To help my understanding, any strong motivating choices for the gif decoder library choice (giflib)? I know there's quite a few out there. |
Author
Not really any strong reasons for it, we could even swap for a Rust based one if you prefer. From a basic research good candidates are:
I will create an alternative PR with the Rust one instead. |
Author
|
Closed in favor of #104 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a gif package with decode support.
The idea is to eventually be able to offer GIF -> Animated WEBP / Animated AVIF using jSquash packages