netpbmfile


Namenetpbmfile JSON
Version 2024.5.24 PyPI version JSON
download
home_pagehttps://www.cgohlke.com
SummaryRead and write Netpbm files
upload_time2024-05-25 16:08:59
maintainerNone
docs_urlNone
authorChristoph Gohlke
requires_python>=3.9
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Read and write Netpbm files
===========================

Netpbmfile is a Python library to read and write image files in the Netpbm
or related formats:

- PBM (Portable Bit Map): P1 (text) and P4 (binary)
- PGM (Portable Gray Map): P2 (text) and P5 (binary)
- PPM (Portable Pixel Map): P3 (text) and P6 (binary)
- PNM (Portable Any Map): shorthand for PBM, PGM, and PPM collectively
- PAM (Portable Arbitrary Map): P7, bilevel, gray, and rgb
- PGX (Portable Graymap Signed): PG, signed grayscale
- PFM (Portable Float Map): Pf (gray), PF (rgb), and PF4 (rgba), read-only
- XV thumbnail: P7 332 (rgb332), read-only

The Netpbm formats are specified at https://netpbm.sourceforge.net/doc/.

The PGX format is specified in ITU-T Rec. T.803.

No gamma correction or scaling is performed.

:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
:License: BSD 3-Clause
:Version: 2024.5.24

Quickstart
----------

Install the netpbmfile package and all dependencies from the
`Python Package Index <https://pypi.org/project/netpbmfile/>`_::

    python -m pip install -U "netpbmfile[all]"

See `Examples`_ for using the programming interface.

Source code and support are available on
`GitHub <https://github.com/cgohlke/netpbmfile>`_.

Requirements
------------

This revision was tested with the following requirements and dependencies
(other versions may work):

- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.9, 3.12.3
- `NumPy <https://pypi.org/project/numpy/>`_ 1.26.4

Revisions
---------

2024.5.24

- Fix docstring examples not correctly rendered on GitHub.

2024.4.24

- Support NumPy 2.

2023.8.30

- Fix linting issues.
- Add py.typed marker.

2023.6.15

- Drop support for Python 3.8 and numpy < 1.21 (NEP29).
- Improve type hints.

2023.1.1

- Several breaking changes:
- Rename magicnum to magicnumber (breaking).
- Rename tupltypes to tupltype (breaking).
- Change magicnumber and header properties to str (breaking).
- Replace pam parameter with magicnumber (breaking).
- Move byteorder parameter from NetpbmFile.asarray to NetpbmFile (breaking).
- Fix shape and axes properties for multi-image files.
- Add maxval and tupltype parameters to NetpbmFile.fromdata and imwrite.
- Add option to write comment to PNM and PAM files.
- Support writing PGX and text formats.
- Add Google style docstrings.
- Add unittests.

2022.10.25

- …

Refer to the CHANGES file for older revisions.

Examples
--------

Write a numpy array to a Netpbm file in grayscale binary format:

>>> data = numpy.array([[0, 1], [65534, 65535]], dtype=numpy.uint16)
>>> imwrite('_tmp.pgm', data)

Read the image data from a Netpbm file as numpy array:

>>> image = imread('_tmp.pgm')
>>> numpy.testing.assert_equal(image, data)

Access meta and image data in a Netpbm file:

>>> with NetpbmFile('_tmp.pgm') as pgm:
...     pgm.magicnumber
...     pgm.axes
...     pgm.shape
...     pgm.dtype
...     pgm.maxval
...     pgm.asarray().tolist()
...
'P5'
'YX'
(2, 2)
dtype('>u2')
65535
[[0, 1], [65534, 65535]]

View the image and metadata in the Netpbm file from the command line::

    $ python -m netpbmfile _tmp.pgm

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.cgohlke.com",
    "name": "netpbmfile",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Christoph Gohlke",
    "author_email": "cgohlke@cgohlke.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/d1/7ac16fe92facce5baa37a771a6e95938beb6bd1bc60055e0f18df2d13f07/netpbmfile-2024.5.24.tar.gz",
    "platform": "any",
    "description": "Read and write Netpbm files\r\n===========================\r\n\r\nNetpbmfile is a Python library to read and write image files in the Netpbm\r\nor related formats:\r\n\r\n- PBM (Portable Bit Map): P1 (text) and P4 (binary)\r\n- PGM (Portable Gray Map): P2 (text) and P5 (binary)\r\n- PPM (Portable Pixel Map): P3 (text) and P6 (binary)\r\n- PNM (Portable Any Map): shorthand for PBM, PGM, and PPM collectively\r\n- PAM (Portable Arbitrary Map): P7, bilevel, gray, and rgb\r\n- PGX (Portable Graymap Signed): PG, signed grayscale\r\n- PFM (Portable Float Map): Pf (gray), PF (rgb), and PF4 (rgba), read-only\r\n- XV thumbnail: P7 332 (rgb332), read-only\r\n\r\nThe Netpbm formats are specified at https://netpbm.sourceforge.net/doc/.\r\n\r\nThe PGX format is specified in ITU-T Rec. T.803.\r\n\r\nNo gamma correction or scaling is performed.\r\n\r\n:Author: `Christoph Gohlke <https://www.cgohlke.com>`_\r\n:License: BSD 3-Clause\r\n:Version: 2024.5.24\r\n\r\nQuickstart\r\n----------\r\n\r\nInstall the netpbmfile package and all dependencies from the\r\n`Python Package Index <https://pypi.org/project/netpbmfile/>`_::\r\n\r\n    python -m pip install -U \"netpbmfile[all]\"\r\n\r\nSee `Examples`_ for using the programming interface.\r\n\r\nSource code and support are available on\r\n`GitHub <https://github.com/cgohlke/netpbmfile>`_.\r\n\r\nRequirements\r\n------------\r\n\r\nThis revision was tested with the following requirements and dependencies\r\n(other versions may work):\r\n\r\n- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.9, 3.12.3\r\n- `NumPy <https://pypi.org/project/numpy/>`_ 1.26.4\r\n\r\nRevisions\r\n---------\r\n\r\n2024.5.24\r\n\r\n- Fix docstring examples not correctly rendered on GitHub.\r\n\r\n2024.4.24\r\n\r\n- Support NumPy 2.\r\n\r\n2023.8.30\r\n\r\n- Fix linting issues.\r\n- Add py.typed marker.\r\n\r\n2023.6.15\r\n\r\n- Drop support for Python 3.8 and numpy < 1.21 (NEP29).\r\n- Improve type hints.\r\n\r\n2023.1.1\r\n\r\n- Several breaking changes:\r\n- Rename magicnum to magicnumber (breaking).\r\n- Rename tupltypes to tupltype (breaking).\r\n- Change magicnumber and header properties to str (breaking).\r\n- Replace pam parameter with magicnumber (breaking).\r\n- Move byteorder parameter from NetpbmFile.asarray to NetpbmFile (breaking).\r\n- Fix shape and axes properties for multi-image files.\r\n- Add maxval and tupltype parameters to NetpbmFile.fromdata and imwrite.\r\n- Add option to write comment to PNM and PAM files.\r\n- Support writing PGX and text formats.\r\n- Add Google style docstrings.\r\n- Add unittests.\r\n\r\n2022.10.25\r\n\r\n- \u2026\r\n\r\nRefer to the CHANGES file for older revisions.\r\n\r\nExamples\r\n--------\r\n\r\nWrite a numpy array to a Netpbm file in grayscale binary format:\r\n\r\n>>> data = numpy.array([[0, 1], [65534, 65535]], dtype=numpy.uint16)\r\n>>> imwrite('_tmp.pgm', data)\r\n\r\nRead the image data from a Netpbm file as numpy array:\r\n\r\n>>> image = imread('_tmp.pgm')\r\n>>> numpy.testing.assert_equal(image, data)\r\n\r\nAccess meta and image data in a Netpbm file:\r\n\r\n>>> with NetpbmFile('_tmp.pgm') as pgm:\r\n...     pgm.magicnumber\r\n...     pgm.axes\r\n...     pgm.shape\r\n...     pgm.dtype\r\n...     pgm.maxval\r\n...     pgm.asarray().tolist()\r\n...\r\n'P5'\r\n'YX'\r\n(2, 2)\r\ndtype('>u2')\r\n65535\r\n[[0, 1], [65534, 65535]]\r\n\r\nView the image and metadata in the Netpbm file from the command line::\r\n\r\n    $ python -m netpbmfile _tmp.pgm\r\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Read and write Netpbm files",
    "version": "2024.5.24",
    "project_urls": {
        "Bug Tracker": "https://github.com/cgohlke/netpbmfile/issues",
        "Homepage": "https://www.cgohlke.com",
        "Source Code": "https://github.com/cgohlke/netpbmfile"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac7a2530d0bf931e93164e41cf16e2e8904939d36b767f5ab2d59ac1dfbaa249",
                "md5": "6593f53a02a0faf5d60e028f8fea2335",
                "sha256": "da2e8a47d83066ab5cdeb95ffb9b5564acbccfcf2b1a92639e1043a544ed4891"
            },
            "downloads": -1,
            "filename": "netpbmfile-2024.5.24-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6593f53a02a0faf5d60e028f8fea2335",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 14032,
            "upload_time": "2024-05-25T16:08:57",
            "upload_time_iso_8601": "2024-05-25T16:08:57.396233Z",
            "url": "https://files.pythonhosted.org/packages/ac/7a/2530d0bf931e93164e41cf16e2e8904939d36b767f5ab2d59ac1dfbaa249/netpbmfile-2024.5.24-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7cd17ac16fe92facce5baa37a771a6e95938beb6bd1bc60055e0f18df2d13f07",
                "md5": "9419f11e34c54d5eeb95451746b12ea6",
                "sha256": "b1458edd5a5e6ceb7637c14dabb45df5cd907e41b6e4499e39811712ce105137"
            },
            "downloads": -1,
            "filename": "netpbmfile-2024.5.24.tar.gz",
            "has_sig": false,
            "md5_digest": "9419f11e34c54d5eeb95451746b12ea6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 29418,
            "upload_time": "2024-05-25T16:08:59",
            "upload_time_iso_8601": "2024-05-25T16:08:59.254052Z",
            "url": "https://files.pythonhosted.org/packages/7c/d1/7ac16fe92facce5baa37a771a6e95938beb6bd1bc60055e0f18df2d13f07/netpbmfile-2024.5.24.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-25 16:08:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cgohlke",
    "github_project": "netpbmfile",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "netpbmfile"
}
        
Elapsed time: 0.82015s