Skip to content

fix: Correct the detection of AVIF disposal and blending methods. #248

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

skidder
Copy link
Contributor

@skidder skidder commented Apr 28, 2025

Improve AVIF animation frame handling

This PR improves the handling of animated AVIF files by updating the frame disposal and blending logic:

  • For animated AVIFs, now uses DISPOSE_BACKGROUND by default to clear previous frames
  • Only uses DISPOSE_NONE for frames with premultiplied alpha
  • Uses BLEND_ALPHA when either premultiplied alpha or alpha plane is present
  • Maintains backward compatibility for non-animated images

These changes ensure proper handling of transparency in animated AVIF sequences, particularly for files with non-premultiplied alpha channels.

Specification Alignment

The changes align with the AVIF specification (ISO/IEC 23008-12):

Frame Disposal

  • DISPOSE_BACKGROUND for non-premultiplied alpha to ensure proper transparency
  • DISPOSE_NONE for premultiplied alpha frames designed for direct compositing

Blending Behavior

  • BLEND_ALPHA when alpha is present (premultiplied or not)
  • BLEND_NONE for frames without transparency

@skidder skidder merged commit 29e8772 into master Apr 28, 2025
5 checks passed
@skidder skidder deleted the skidder/fix-avif-dispose branch April 28, 2025 18:33
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

Successfully merging this pull request may close these issues.

2 participants