Skip to content
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

Make the Frame struct Pixel-agnostic? #2398

Open
moulins opened this issue Dec 29, 2024 · 2 comments
Open

Make the Frame struct Pixel-agnostic? #2398

moulins opened this issue Dec 29, 2024 · 2 comments

Comments

@moulins
Copy link

moulins commented Dec 29, 2024

The Frames returned by AnimationDecoder are hardcoded to contain Rgba8Images, which is generally suboptimal when working with animated PNG or WEBP images:

  • if the source image has no alpha channel, this imposes an extra conversion;
  • 16-bit APNGs are unsupported because of this.

Would it make sense to have Frame contain a DynamicImage instead of a Rgba8Image, despite the fact that this is a breaking change? Existing users of the API could easily upgrade by doing the conversion to Rgba8 manually with .into_buffer().into_rgba8() or similar.

@kornelski
Copy link
Contributor

It would be nice to have.

It might be doable in a backwards-compatible way by adding a new method next to into_frames, like into_frames_dynamic().

However, I don't think it has practical utility besides optimization for opaque RGB8. AFAIK WebP doesn't have 16-bit coding — lossless is 8-bit-only, and VP8 implementations don't even use full range in 8 bits. PNG compression is pretty bad in 16 bits.

@moulins
Copy link
Author

moulins commented Jan 4, 2025

You're right that this would be mostly for optimization purposes; another theoretical use-case would be grayscale APNGs, but I'd be surprised if they actually exist in the wild ^^

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

No branches or pull requests

2 participants