How can I programmatically create APNG files?
Asked Answered
J

1

6

Generally I use PHP, and ImageMagick, but as far as I can tell it seems the ImageMagick group refuse to implement the ability to create/understand animated PNG files?

What tooling can I implement to take a dozen JPEG files and create an animated PNG out of them? I'd prefer to have a PHP api, but I can branch out into another language if required!

Thanks

Juliannejuliano answered 1/5, 2019 at 9:53 Comment(5)
Maybe this? github.com/eight04/pyAPNGGeophyte
Why do you use APNG? It has never been widely supported. WebP has got a lot more traction.Aker
AFAIK you're wrong, APNG actually has better support than WebP. caniuse.com/#feat=apng caniuse.com/#feat=webp Crucially WebP is missing MacOS/iOS Safari support, which is HUGE, where in contrast APNG misses IE11/Edge, which is a tiny percentage (and declining) of my users.Juliannejuliano
Edge now supports APNG.Polarimeter
@orionelenzil But sadly not PowerpointDistinctly
P
11

As of ImageMagick 7.0.10-31, Animated PNG is supported.

magick -delay 100 -loop 0 frame1.png frame2.png APNG:myanimation.png

parameters:
-delay 100 specifies a duration of 100 centiseconds (aka one second) per frame before moving on to the next frame.
-loop 0 tells the animation to repeat forever.
APNG:___.png specifies the output should be animated png.

(thanks to @fmw42 for improvements)

note: on MacOS Ventura, this seems to require ffmpeg as well.

Polarimeter answered 25/10, 2021 at 23:25 Comment(6)
Your syntax is not actually correct. You specify it properly as magick -delay 100 -loop 0 frame1.png frame2.png APNG:myanimatedpng.png Note the APNG: preface and that it is actually a sub function of png. Also in Imagemagick 7, use magick, not magick convert. The changelog lists it as added 7.0.10.31Seizing
thank you for these. updated. in my own work I realized "apng:foo.png" was better, but forgot to come back and edit my answer.Polarimeter
I did give you an up vote for your answer anyway already as you properly noted that Imagemagick can do that.Seizing
lol, i keep searching "imagemagick animated png" and coming back to this page and upvoting this answer and then wondering why my upvote isn't working.Polarimeter
You can only upvote once on any given topic. Also you cannot upvote your own answer.Seizing
:) yes, i know. i keep forgetting it's my answer.Polarimeter

© 2022 - 2024 — McMap. All rights reserved.