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

Fix Animated WebP Support: Canvas Size Detection and Alpha Channel Handling #3

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

skidder
Copy link

@skidder skidder commented Aug 25, 2024

Includes changes in PR submitted to Piexif project: hMatoba#146

Description

This pull request addresses two key issues related to handling animated WebP files in the Piexif library:

  1. Canvas Size Detection:

    • Issue: Incorrect VP8X Canvas Dimensions in Animated WebP Files hMatoba/Piexif#145
    • Previously, the VP8X chunk dimensions were incorrectly set based on the last frame encountered, which could result in canvas dimensions being too small when frames of varying sizes were present.
    • The code has been updated to track the maximum width and height across all frames, ensuring that the VP8X chunk accurately reflects the overall canvas size.
  2. Alpha Channel Detection for Animated Frames:

    • Issue: Incorrect Detection of Nested ALPH Chunk in Animated WebP Files hMatoba/Piexif#144
    • The library failed to correctly detect and set the alpha flag in the VP8X chunk for animated WebP files where ALPH chunks were nested within ANMF chunks.
    • A new function, _get_sub_chunks_from_anmf, has been introduced to recursively examine sub-chunks within ANMF chunks while preventing excessive recursion through a depth limit.
    • This ensures that the alpha flag is properly set when transparency data is present in any frame of the animation.

Testing

  • Verified the correctness of canvas size detection and alpha channel handling by running the included tests with various animated WebP files.
  • Confirmed that the changes do not introduce any regressions for non-animated WebP files.

@skidder skidder force-pushed the skidder/fix-animated-webp-support branch from 8305670 to d6d4bd3 Compare August 25, 2024 15:56
Copy link

@nulltrope nulltrope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, appreciate the detailed PR description & tests. Also nice we're upstreaming these fixes :)

@skidder skidder merged commit 00542be into master Aug 26, 2024
@skidder skidder deleted the skidder/fix-animated-webp-support branch August 26, 2024 14:59
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