-
Notifications
You must be signed in to change notification settings - Fork 255
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
feat: add support for webp images #622
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Ready for a review! @shuding |
This looks cool! I can help if needed. I have a use case which I needed it for. |
The main problem here is that Satori only handles HTML/CSS → SVG, but the downstream solutions (vercel/og and Resvg.js) that render the SVG as an image don't support WebP inside the SVG yet. This means that even if WebP is added here, it's still not possible to render the source to rasterized images (PNG, JPEG, etc). Current blockers to get this landed: |
good news, resvg merged their webp support! |
I made my own version with webp support with resvg-js 2.6.2 last night just to test it. While Satori SVGs with webp work fine, @resvg/resvg-js is still a blocker as it isn't on 0.43.0 or newer. Looks like an upgrade to 0.38.0 is still in progress at this time. |
Summary
This pull request introduces a new method to parse WEBP images and extract their dimensions. The implementation is based on the WEBP container specifications and currently supports the following WEBP specifications:
Details
The method reads and verifies the WEBP file header, then iterates through the file's chunks to extract the image dimensions. It performs necessary boundary checks to ensure the integrity of the data being read.
Specifications and References
WEBP Container Specification: Google Developers - RIFF Container
General WEBP Information: Google Developers - WEBP
Test Images: Images used for testing were sourced from Google Developers - WEBP Gallery
Fixes: #607
Fixes: #539
Fixes: #273
Fixes: #311