Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A Python module to deal with APNG file.

Project description Documentation Status

A Python module to deal with APNG file.


  • Merge multiple images into one APNG file. (It use Pillow to convert images into PNG format)
  • Read APNG file and extract each frames into PNG file.
  • It doesn’t do any optimization but only concat the images. This might be changed in the future.


  • Pillow - Optional. You can still use pyAPNG without PIL but it can only read PNG files.

Development dependencies

  • pngcheck
  • See requirements.txt for other dev-dependencies.


From pypi:

pip install apng


Convert a series of images into APNG animation:

from apng import APNG

APNG.from_files(["1.jpg", "2.jpg", "3.jpg"], delay=100).save("result.png")

Use different delays:

from apng import APNG

files = [
  ("1.jpg", 100),
  ("2.jpg", 200),
  ("3.jpg", 300)

im = APNG()
for file, delay in files:
  im.append_file(file, delay=delay)"result.png")

Extract frames from an APNG file:

from apng import APNG

im ="animation.png")
for i, (png, control) in enumerate(im.frames):"{i}.png".format(i=i))

Add a text chunk to the PNG file:

from apng import PNG, make_text_chunk

im ="image.png")
im.chunks.append(make_text_chunk(key="Comment", value="Some text"))"image.png")


If you want to convert some large JPGs into animation, the library has to convert your JPGs into PNGs then merge them into a single animation APNG file. The problems are:

  1. It is extremely slow.
  2. The file size of the APNG is extremely large. Probably 5x of the original or more.

In this case, I suggest trying an animation format called “ugoira”, which is implemented by There is also an image viewer named “HoneyView” which can view it locally.


  • Add optimizer?


  • 0.3.4 (Mar 11, 2020)
    • Fix: exclude test files from the package.
  • 0.3.3 (Feb 11, 2019)
    • Fix: failed to extract frames containing multiple fdAT chunks.
  • 0.3.2 (Jul 20, 2018)
    • Add: make_text_chunk function.
    • Add: Chunk data class.
    • Change: now parse_chunks yields Chunk instead of a tuple. This should be safe since Chunk is a namedtuple.
  • 0.3.1 (May 13, 2018)
    • Add: universal wheel.
  • 0.3.0 (May 13, 2018)
    • Support Python 2.
    • Add: PNG method open_any, from_bytes.
    • Add: APNG method append_file, from_bytes.
    • Add: module function parse_chunks.
    • Drop: module function `is_png` and `chunks`.
    • Change: `` now only reads PNG images. To read non-PNG images, use `PNG.open_any`.
    • Change: `APNG.append` now only accepts `PNG` instance. To append PNG files, use `APNG.append_file`.
  • 0.2.1 (Apr 19, 2018)
    • Add: support num_plays. (#4)
  • 0.2.0 (Dec 8, 2017)
    • Add test.
    • Add documents.
    • Add: support path-like object.
    • Fix: some chunks must appear before IDAT. (#1)
    • Fix: change chunks order in APNG. Some chunks are moved to the end of the file.
    • Fix: remove tRNS hack.
    • Fix: is_png shouldn’t move file pointer. (#2)
  • 0.1.0 (May 30, 2016)
    • First release.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for apng, version 0.3.4
Filename, size File type Python version Upload date Hashes
Filename, size apng-0.3.4-py2.py3-none-any.whl (8.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size apng-0.3.4.tar.gz (8.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page