imagemagickapng

How can I programmatically create APNG files?


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


Solution

  • 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.