The tests will fail for pil_animated3.webp due to the unexpected presence of an ALPH chunk in the output file since the Alpha flag was incorrect removed from the VP8X flags. The webpinfo tool confirms this:
The piexif library should correctly identify the structure of the WebP file and detect ALPH chunks that are present at the appropriate levels. Specifically, the presence of an ALPH chunk nested within an ANMF chunk should correctly set the animation flag in the VP8X chunk at the container level. The WebP Extended File Format allows for the ANMF chunk to contain an ALPH sub-chunk which, if present, must result in the VP8X chunk Animation flag being enabled.
Actual Behavior:
The library fails to detect the nested ALPH chunk correctly, resulting in incorrect flag settings in the VP8X chunk. This causes the library to corrupts the contents of animated WebP files.
Technical Details:
The issue seems to stem from the set_vp8x function, which does not recursively check for ALPH chunks nested within ANMF chunks. As a result, the library fails to set the animation flag correctly.
WebP Image (OK)
The detection of ALPH chunks works fine for single frame, non-animated WebP files having a structure like the following:
Summary
Piexif corrupts the
VP8X
flags for animated WebP data.Steps to Reproduce
The following commit on my fork adds two animated webp test files: https://github.com/hMatoba/Piexif/commit/5a12974343580d5f6fbbed74966bc56f2859ffe9
The tests will fail for
pil_animated3.webp
due to the unexpected presence of anALPH
chunk in the output file since the Alpha flag was incorrect removed from theVP8X
flags. Thewebpinfo
tool confirms this:Input Test File
Output Test File
Proposal
Recursively examine sub-chunks within the
ANMF
chunk. I have a commit on my fork that could work for this: https://github.com/hMatoba/Piexif/commit/fe92a5b007668a8c444948b371ced8c2bd84a7dfExpected Behavior:
The piexif library should correctly identify the structure of the WebP file and detect
ALPH
chunks that are present at the appropriate levels. Specifically, the presence of anALPH
chunk nested within anANMF
chunk should correctly set the animation flag in theVP8X
chunk at the container level. The WebP Extended File Format allows for theANMF
chunk to contain anALPH
sub-chunk which, if present, must result in theVP8X
chunkAnimation
flag being enabled.Actual Behavior:
The library fails to detect the nested
ALPH
chunk correctly, resulting in incorrect flag settings in theVP8X
chunk. This causes the library to corrupts the contents of animated WebP files.Technical Details:
The issue seems to stem from the
set_vp8x
function, which does not recursively check forALPH
chunks nested withinANMF
chunks. As a result, the library fails to set the animation flag correctly.WebP Image (OK)
The detection of
ALPH
chunks works fine for single frame, non-animated WebP files having a structure like the following:Animated WebP (Broken)
The issue arises with animated WebP files having a nested
ALPH
sub-chunk: