-
Notifications
You must be signed in to change notification settings - Fork 5.8k
feat(ext/canvas): support gif, webp for createImageBitmap
#31402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe PR adds GIF and WebP support to createImageBitmap: it removes early MIME-type rejections in the JS canvas layer, enables "gif" and "webp" features in ext/canvas/Cargo.toml, implements GIF and WebP decoding in Rust (returning DynamicImage plus orientation and ICC profile), and updates tests to create imageBitmaps for GIF/WEBP (and other formats) and assert bitmap data instead of expecting rejections. Sequence DiagramsequenceDiagram
actor Client
participant JS as JS canvas layer
participant Rust as Rust decoder layer
participant Tests as Test suite
rect rgb(250,245,240)
Note over Client,JS: Request flow (after changes)
Client->>JS: createImageBitmap(blob with GIF/WEBP)
JS->>JS: MIME check (no early rejection for GIF/WEBP)
JS->>Rust: decodeImage(blob)
rect rgb(230,250,240)
Rust->>Rust: Instantiate GifDecoder/WebPDecoder
Rust->>Rust: Decode frames -> DynamicImage
Rust->>Rust: Extract orientation & ICC profile
Rust-->>JS: Return bitmap + metadata
end
JS->>Client: Resolve ImageBitmap
Client->>Tests: Test reads bitmap via Deno.internal.getBitmapData
Tests->>Tests: Assert bitmap contents, dimensions, format
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)ext/canvas/op_create_image_bitmap.rs (2)
🔇 Additional comments (3)
Comment |
Summary
continues from #25517
The PR(#28470) gave us a chance to reconsider supporting gif and webp, which we had previously abandoned.
I can also confirm that there is demand for webp at least. #25517 (comment)
build size
on main at 1146973
this PR
about 263kb larger