UPNG.js now supports Animated PNGs!
GitHub - photopea/UPNG.js: Fast and advanced PNG (APNG) decoder and encoder (lossy / lossless)
A small, fast and advanced PNG / APNG encoder and decoder. It is the main PNG engine for Photopea image editor.
Download and include the UPNG.js
file in your code, or get it from NPM:
UPNG.js supports APNG and the interface expects "frames". Regular PNG is just a single-frame animation (single-item array).
imgs
: array of frames. A frame is an ArrayBuffer containing the pixel data (RGBA, 8 bits per channel)w
,h
: width and height of the imagecnum
: number of colors in the result; 0: all colors (lossless PNG)dels
: array of delays for each frame (only when 2 or more frames)- returns an ArrayBuffer with binary data of a PNG file