phppngapng

Does PHP support APNG files?


Apparently all the major popular browsers support the APNG format (https://caniuse.com/?search=apng).

PHP graphics functions (imagecreatefrom… and image…) don’t include specific functions for the APNG format. However, APNG is designed to masquerade as PNG.

So, the question is whether it’s ok to use the PNG functions with APNG files.


Solution

  • If I google it I find the APNG File Format. Here it says:

    APNG files are stored as binary files on disc and use the extended specifications of PNG for animated images. The first frame of an APNG file is a normal PNG stream that is readable by PNG decoders for display.

    So you can use the PHP PNG functions with APNG files but they will only operate on the first frame of the animation.

    To use all of the frames in an animated PNG file, I would suggest to to use one of the ImageMagick extensions.