Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

3 participants