Skip to content

Leave animated PNGs to the OptiPNG pass - #159

Open
happyarts wants to merge 1 commit into
fhanau:masterfrom
happyarts:fix/keep-apng
Open

happyarts wants to merge 1 commit into
fhanau:masterfrom
happyarts:fix/keep-apng

Conversation

@happyarts

Copy link
Copy Markdown

ECT breaks animated PNGs. The ZopfliPNG pass may reduce the default image (e.g. RGBA to palette) and then copies the fdAT chunks back unchanged, so every frame after the first decodes to garbage. With -strip the animation is dropped instead.

OptiPNG already skips reductions for APNGs, so this makes Zopflipng() skip files with an acTL chunk. APNGs now keep all frames in every mode; above -1 they are otherwise left as they are. Regular PNGs give byte-identical output to master.

Tested with a 3-frame APNG in -1, -3, -5 --strict, -9, --allfilters and with -strip, and with truncated files in a hardened libc++ build.

🤖 Generated with Claude Code

The ZopfliPNG pass re-encodes the default image, possibly with a new
color type or bit depth (e.g. RGBA -> palette), and then copies the
remaining chunks back unchanged. For an APNG those include the fdAT
frames, which are still encoded in the original color type, so every
frame after the first decodes to garbage. With -strip the animation
chunks are not copied back and the APNG becomes a still image.

OptiPNG already avoids reductions for APNGs, so skip the ZopfliPNG pass
for files with an acTL chunk before IDAT. Other PNGs are unchanged
(byte-identical output).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant