Skip to content

Add APNG backend for animations - #45

Merged
certik merged 2 commits into
fortran-lang:mainfrom
jalvesz:dev
Nov 5, 2026
Merged

certik merged 2 commits into
fortran-lang:mainfrom
jalvesz:dev

Conversation

@jalvesz

@jalvesz jalvesz commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #39

save_animation now also writes animated PNG when the file name ends in .png or .apng, keeping full colour instead of the GIF 256-colour palette.

  • fplotlib_png: the filter and deflate step of png_encode moved into a shared helper; new apng_encode writes acTL, fcTL, IDAT/fdAT (whole, opaque frames; frame 1 doubles as the fallback image). Delay is stored as a fraction, so fps is not rounded to 1/100 s.
  • Tests: an APNG reader in test_image_io, and an APNG variant of anim_sine with new fingerprints (existing ones unchanged).
  • README updated.

Not done: delta/cropped frames (output is larger than it could be).

Frames written to a .png or .apng file are stored as full-colour RGB
instead of being quantised to a 256 colour GIF palette. The deflate and
scanline filtering of png_encode is shared with the new apng_encode.
@jalvesz
jalvesz marked this pull request as ready for review November 5, 2026 08:17
@jalvesz
jalvesz requested a review from certik November 5, 2026 08:17
Comment thread src/fplotlib_png.f90 Resolved
test do concurrent

@certik certik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great!

@certik
certik merged commit 64f4540 into fortran-lang:main Nov 5, 2026
7 checks passed
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.

Add APNG backend

2 participants