apng


Nameapng JSON
Version 0.3.4 PyPI version JSON
download
home_pagehttps://github.com/eight04/pyAPNG
SummaryA Python module to deal with APNG file.
upload_time2020-03-11 05:12:10
maintainer
docs_urlNone
authoreight
requires_python
licenseMIT
keywords png apng image convert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            pyAPNG
======

.. image:: https://travis-ci.org/eight04/pyAPNG.svg?branch=master
  :target: https://travis-ci.org/eight04/pyAPNG

.. image:: https://readthedocs.org/projects/pyapng/badge/?version=latest
  :target: http://pyapng.readthedocs.io/en/latest/?badge=latest
  :alt: Documentation Status

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 <https://github.com/python-pillow/Pillow>`__ - **Optional**. You can still use pyAPNG without PIL but it can only read PNG files.

Development dependencies
------------------------

- `pngcheck <http://www.libpng.org/pub/png/apps/pngcheck.html>`_
- See requirements.txt for other dev-dependencies.

Installation
------------

From `pypi <https://pypi.org/project/apng/>`__::

  pip install apng

Usage
-----

Convert a series of images into APNG animation:

.. code:: python

  from apng import APNG

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

Use different delays:

.. code:: python

  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:

.. code:: python

  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:

.. code:: python

  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:

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 Pixiv.net. There is also an image viewer named "HoneyView" which can view it locally.

Document
---------

http://pyapng.readthedocs.io/en/latest/

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 <https://github.com/eight04/pyAPNG/issues/4>`_)

- 0.2.0 (Dec 8, 2017)

  - Add test.
  - Add documents.
  - Add: support path-like object.
  - Fix: some chunks must appear before IDAT. (`#1 <https://github.com/eight04/pyAPNG/issues/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 <https://github.com/eight04/pyAPNG/pull/2>`_)

- 0.1.0 (May 30, 2016)

  - First release.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/eight04/pyAPNG",
    "name": "apng",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "png,apng,image,convert",
    "author": "eight",
    "author_email": "eight04@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2b/fe/45f21b8a2236bf6079daf1fccde5c839b881192bb474f3a49ef9ae35e4be/apng-0.3.4.tar.gz",
    "platform": "",
    "description": "pyAPNG\n======\n\n.. image:: https://travis-ci.org/eight04/pyAPNG.svg?branch=master\n  :target: https://travis-ci.org/eight04/pyAPNG\n\n.. image:: https://readthedocs.org/projects/pyapng/badge/?version=latest\n  :target: http://pyapng.readthedocs.io/en/latest/?badge=latest\n  :alt: Documentation Status\n\nA Python module to deal with APNG file.\n\nFeatures\n--------\n\n- Merge multiple images into one APNG file. (It use Pillow to convert images into PNG format)\n- Read APNG file and extract each frames into PNG file.\n- It doesn't do any optimization but only concat the images. This might be changed in the future.\n\nDependencies\n------------\n\n- `Pillow <https://github.com/python-pillow/Pillow>`__ - **Optional**. You can still use pyAPNG without PIL but it can only read PNG files.\n\nDevelopment dependencies\n------------------------\n\n- `pngcheck <http://www.libpng.org/pub/png/apps/pngcheck.html>`_\n- See requirements.txt for other dev-dependencies.\n\nInstallation\n------------\n\nFrom `pypi <https://pypi.org/project/apng/>`__::\n\n  pip install apng\n\nUsage\n-----\n\nConvert a series of images into APNG animation:\n\n.. code:: python\n\n  from apng import APNG\n\n  APNG.from_files([\"1.jpg\", \"2.jpg\", \"3.jpg\"], delay=100).save(\"result.png\")\n\nUse different delays:\n\n.. code:: python\n\n  from apng import APNG\n\n  files = [\n    (\"1.jpg\", 100),\n    (\"2.jpg\", 200),\n    (\"3.jpg\", 300)\n  ]\n\n  im = APNG()\n  for file, delay in files:\n    im.append_file(file, delay=delay)\n  im.save(\"result.png\")\n\nExtract frames from an APNG file:\n\n.. code:: python\n\n  from apng import APNG\n\n  im = APNG.open(\"animation.png\")\n  for i, (png, control) in enumerate(im.frames):\n    png.save(\"{i}.png\".format(i=i))\n\nAdd a text chunk to the PNG file:\n\n.. code:: python\n\n  from apng import PNG, make_text_chunk\n\n  im = PNG.open(\"image.png\")\n  im.chunks.append(make_text_chunk(key=\"Comment\", value=\"Some text\"))\n  im.save(\"image.png\")\n\nPerformance\n-----------\n\nIf 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:\n\n1. It is extremely slow.\n2. The file size of the APNG is extremely large. Probably 5x of the original or more.\n\nIn 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.\n\nDocument\n---------\n\nhttp://pyapng.readthedocs.io/en/latest/\n\nTodos\n-----\n\n- Add optimizer?\n\nChangelog\n---------\n\n- 0.3.4 (Mar 11, 2020)\n\n  - Fix: exclude test files from the package.\n\n- 0.3.3 (Feb 11, 2019)\n\n  - Fix: failed to extract frames containing multiple ``fdAT`` chunks.\n\n- 0.3.2 (Jul 20, 2018)\n\n  - Add: ``make_text_chunk`` function.\n  - Add: ``Chunk`` data class.\n  - Change: now ``parse_chunks`` yields ``Chunk`` instead of a tuple. This should be safe since ``Chunk`` is a namedtuple.\n\n- 0.3.1 (May 13, 2018)\n\n  - Add: universal wheel.\n\n- 0.3.0 (May 13, 2018)\n\n  - Support Python 2.\n  - Add: PNG method ``open_any``, ``from_bytes``.\n  - Add: APNG method ``append_file``, ``from_bytes``.\n  - Add: module function ``parse_chunks``.\n  - **Drop: module function `is_png` and `chunks`.**\n  - **Change: `PNG.open` now only reads PNG images. To read non-PNG images, use `PNG.open_any`.**\n  - **Change: `APNG.append` now only accepts `PNG` instance. To append PNG files, use `APNG.append_file`.**\n\n- 0.2.1 (Apr 19, 2018)\n\n  - Add: support num_plays. (`#4 <https://github.com/eight04/pyAPNG/issues/4>`_)\n\n- 0.2.0 (Dec 8, 2017)\n\n  - Add test.\n  - Add documents.\n  - Add: support path-like object.\n  - Fix: some chunks must appear before IDAT. (`#1 <https://github.com/eight04/pyAPNG/issues/1>`_)\n  - Fix: change chunks order in APNG. Some chunks are moved to the end of the file.\n  - Fix: remove tRNS hack.\n  - Fix: is_png shouldn't move file pointer. (`#2 <https://github.com/eight04/pyAPNG/pull/2>`_)\n\n- 0.1.0 (May 30, 2016)\n\n  - First release.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python module to deal with APNG file.",
    "version": "0.3.4",
    "project_urls": {
        "Homepage": "https://github.com/eight04/pyAPNG"
    },
    "split_keywords": [
        "png",
        "apng",
        "image",
        "convert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65dbb3f4bf6cd1584e9f2ef903b7e3d1a4b209b98caccf336baa56da18e43e8f",
                "md5": "1b4d32ca67e92d4f03dd1a4043a04be2",
                "sha256": "6cb5d09d2c5cfd12226a13e64e731dcf94a399ba252d122309134a86ce14c942"
            },
            "downloads": -1,
            "filename": "apng-0.3.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1b4d32ca67e92d4f03dd1a4043a04be2",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 8172,
            "upload_time": "2020-03-11T05:12:08",
            "upload_time_iso_8601": "2020-03-11T05:12:08.275774Z",
            "url": "https://files.pythonhosted.org/packages/65/db/b3f4bf6cd1584e9f2ef903b7e3d1a4b209b98caccf336baa56da18e43e8f/apng-0.3.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2bfe45f21b8a2236bf6079daf1fccde5c839b881192bb474f3a49ef9ae35e4be",
                "md5": "41e57ca90203ce32ca990a99f19acb16",
                "sha256": "a3e4007fbadab2188ef80490bff4e75acc847158d22ec97176f6040ff76465ae"
            },
            "downloads": -1,
            "filename": "apng-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "41e57ca90203ce32ca990a99f19acb16",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8599,
            "upload_time": "2020-03-11T05:12:10",
            "upload_time_iso_8601": "2020-03-11T05:12:10.004350Z",
            "url": "https://files.pythonhosted.org/packages/2b/fe/45f21b8a2236bf6079daf1fccde5c839b881192bb474f3a49ef9ae35e4be/apng-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-03-11 05:12:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eight04",
    "github_project": "pyAPNG",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "apng"
}
        
Elapsed time: 0.18472s