pyAPNG
A Python module to deal with APNG file.
Features
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.
Dependencies
Pillow - Optional. You can still use pyAPNG without PIL but it can only read PNG files.
Development dependencies
See requirements.txt for other dev-dependencies.
Installation
From pypi:
pip install apng
Usage
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)
im.save("result.png")
Extract frames from an APNG file:
from apng import APNG
im = APNG.open("animation.png")
for i, (png, control) in enumerate(im.frames):
png.save("{i}.png".format(i=i))
Add a text chunk to the PNG file:
from apng import PNG, make_text_chunk
im = PNG.open("image.png")
im.chunks.append(make_text_chunk(key="Comment", value="Some text"))
im.save("image.png")
Performance
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:
It is extremely slow.
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 Pixiv.net. There is also an image viewer named “HoneyView” which can view it locally.
Document
Todos
Add optimizer?
Changelog
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: `PNG.open` 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)
0.1.0 (May 30, 2016)
First release.
Metadata
Release files for apng 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apng-0.3.4.tar.gz | 8.6 kB | Without provenance | Details for apng-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apng-0.3.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for apng-0.3.4-py2.py3-none-any.whl |
Total release size: 16.8 kB
Release files / apng-0.3.4.tar.gz
| Download URL | apng-0.3.4.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3e4007fbadab2188ef80490bff4e75acc847158d22ec97176f6040ff76465ae
|
|
BLAKE2b-256 checksum How to use checksums |
2bfe45f21b8a2236bf6079daf1fccde5c839b881192bb474f3a49ef9ae35e4be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
|
Release files / apng-0.3.4-py2.py3-none-any.whl
| Download URL | apng-0.3.4-py2.py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6cb5d09d2c5cfd12226a13e64e731dcf94a399ba252d122309134a86ce14c942
|
|
BLAKE2b-256 checksum How to use checksums |
65dbb3f4bf6cd1584e9f2ef903b7e3d1a4b209b98caccf336baa56da18e43e8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
|
Security for apng 0.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.