Animated PNG (APNG): Compatibility, File Size and Conversion
Cover animation chunks, fallback frames, browser/app support, optimization and GIF/WebP tradeoffs.
How APNG stores animation inside a PNG container
A standard PNG ends after one IDAT chunk and a closing IEND. An APNG inserts extra chunks between them:
acTL(Animation Control): declares total frame count and loop behavior. A value of 0 means infinite looping.fcTL(Frame Control): per-frame metadata — offset, dimensions, delay in milliseconds, and disposal method (how the previous frame is handled when the next one draws).fdAT(Frame Data): compressed pixel data for each animation frame, structurally identical toIDAT.
A decoder that does not recognize acTL ignores it as an ancillary chunk and renders only the first IDAT. That first frame is the fallback frame — the single image every non-APNG viewer displays.
The fallback frame determines what static viewers see
The PNG specification states that "decoders that do not understand the animation chunks shall display only the first frame" (PNG 3rd Edition, §12.4). If your first frame is a placeholder, a blank canvas, or a low-resolution thumbnail, that is exactly what users on unsupported platforms will see. If the first frame is a complete composite of the final animation state, static viewers get a reasonable still image.
Diagnostic check: Open the file in a hex viewer or PNG chunk inspector. Search for the ASCII string acTL near offset 50–100. If present, the file is an APNG. If you see only IHDR, IDAT, and IEND, the file is a static PNG — your export tool may have produced a frame sequence instead of a single animated file.
Browser and application support
Browsers that play APNG
- Firefox: supported since version 3.0 (2008).
- Chrome and Chromium-based browsers (Edge, Brave, Opera): supported since 2010.
- Safari: does not natively decode APNG as of Safari 18 and iOS 18. The file displays as a static fallback frame. Extensions may add support, but you cannot assume Safari visitors see animation.
- Internet Explorer and legacy Edge: no support.
Applications that strip or ignore animation
- Discord, Slack, Telegram: uploads are converted to static PNG. Animated avatars and stickers will not animate.
- Twitter / X: does not play APNG. Use GIF or MP4.
- Email clients: Gmail and Outlook strip animation chunks. Recipients see only the fallback frame.
- Game engines (Unity, Godot, Unreal): most do not parse
acTL. They load the first frame. Use sprite sheets or frame sequences instead.
Desktop image viewers
- APNG-capable: XnView, IrfanView, GIMP (with plugin), most Linux image viewers.
- Static only: macOS Preview, Windows Photos.
File size constraints and optimization
APNG compresses each frame independently with DEFLATE. It applies no inter-frame compression. Two frames that differ by a single pixel are both stored in full.
Size comparison for a 320×240, 30-frame animation:
| Format | Approximate size | Compression method |
|---|---|---|
| APNG (lossless) | 8–15 MB | Per-frame DEFLATE only |
| GIF (256 colors) | 1–3 MB | Changed-pixel encoding, palette limit |
| WebP (lossless) | 3–6 MB | Inter-frame prediction |
| WebP (lossy) | 200–800 KB | Inter-frame prediction with quality tradeoff |
Optimization steps with observable results:
- Reduce frame rate: 10–15 fps is often sufficient for short loops. A 1-second animation at 10 fps uses 10 frames instead of 30. Check playback smoothness after reduction.
- Crop to the animated region: if only a portion of the canvas changes, crop all frames to that bounding box before export. Verify that the cropped output still aligns correctly.
- Reduce color depth: convert source frames to 8-bit grayscale or a 256-color palette with
pngquantbefore assembling the APNG. Confirm that banding or dithering artifacts are acceptable. - Strip metadata: run
pngcrush -rem allaon the final file. Check file size before and after to confirm chunk removal.
Hard limit: PNG chunk length is a 4-byte unsigned integer, capping the file at 2³¹ bytes (approximately 2 GB). Practical limits are lower — a 1,000-frame animation at 1920×1080 will exceed workable web sizes long before hitting the structural cap.
When to choose APNG, GIF, or WebP
Use APNG when
- Lossless output is required (scientific imaging, line art, pixel art).
- Full 8-bit alpha transparency per pixel is needed. GIF supports only binary transparency — fully opaque or fully transparent.
- The audience uses a controlled environment (Chromium-only kiosk, Firefox-based intranet).
- An existing PNG pipeline makes adding a new codec impractical.
Use GIF when
- Universal browser and email client support is required, including Safari.
- The animation uses 256 or fewer colors.
- File size matters more than color fidelity.
Use WebP when
- Smaller file sizes are needed and you control the serving environment (Content-Type negotiation).
- Target browsers include Safari 14+, Chrome, Firefox, and Edge.
- Longer or higher-framerate animations must stay small. WebP's inter-frame compression handles this better than APNG.
Tradeoff: lossy WebP introduces compression artifacts that may be unacceptable for text-heavy or pixel-art animations. APNG preserves every pixel exactly but produces files 5–10× larger.
Conversion commands
APNG to GIF
convert input.png -coalesce -layers remove-duplicates -fuzz 2% output.gif
-coalesce expands APNG frames into a full sequence. -fuzz merges near-identical frames. Expect color banding if the source exceeds 256 colors.
APNG to WebP (lossless)
ffmpeg -i input.png -c:v libwebp -lossless 1 -loop 0 output.webp
Omit -lossless 1 for lossy output. WebP retains transparency and 24-bit color.
APNG to static PNG sequence
apng2png input.png output_prefix.png
Each frame is extracted as a numbered file for reassembly into sprite sheets or video.
Verifying an APNG works
Test in three environments:
- APNG-capable viewer: open in Firefox or XnView. Confirm playback speed and loop count match expectations.
- Static viewer: open in macOS Preview or Windows Photos. Confirm the fallback frame is a reasonable still image, not a placeholder or blank canvas.
- Chunk analyzer: upload to a PNG chunk inspection tool. Verify
acTLframe count matches the intended number. CheckfcTLdelay values — a delay of 0 may cause erratic playback. The specification notes that "a delay of 0 should be treated as the smallest possible delay" (PNG 3rd Edition, §12.4), which some decoders interpret as skipping the frame entirely.
Common causes of failure:
- Incorrect chunk ordering:
acTLmust appear before the firstfcTL. - Fallback frame placed after animation chunks, causing static viewers to display garbage.
- Missing
tEXtchunk with keySoftwarethat some viewers use to identify APNG.
When APNG is the wrong choice
- Email or social media delivery: use GIF or MP4. APNG frames are stripped.
- Safari support required: use GIF or WebP.
- Animations longer than roughly 5 seconds: file size becomes prohibitive without temporal compression. Use WebP or video.
- Discord, Slack, or Telegram icons and stickers: animation is removed on upload. Export a static PNG with only the intended fallback frame.
APNG fits a narrow set of cases: lossless, alpha-transparent, looped animations in Chromium-based environments. For broader compatibility, convert to GIF. For modern compression with good quality, use WebP. Keep original animation source files — conversion from APNG is lossy or structure-altering and cannot be reversed.