https://github.com/cgohlke/netpbmfile

Read and write Netpbm files.

https://github.com/cgohlke/netpbmfile

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.2%) to scientific vocabulary

Keywords

format-reader image netpbm python
Last synced: 5 months ago · JSON representation

Repository

Read and write Netpbm files.

Basic Info
Statistics
  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
format-reader image netpbm python
Created almost 6 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog License

README.rst

..
  This file is generated by setup.py

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 `_
:License: BSD-3-Clause
:Version: 2025.5.8

Quickstart
----------

Install the netpbmfile package and all dependencies from the
`Python Package Index `_::

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

See `Examples`_ for using the programming interface.

Source code and support are available on
`GitHub `_.

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

- `CPython `_ 3.10.11, 3.11.9, 3.12.9, 3.13.2 64-bit
- `NumPy `_ 2.2.5

Revisions
---------

2025.5.8

- Remove doctest command line option.

2025.1.1

- Improve type hints.
- Drop support for Python 3.9, support Python 3.13.

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:

.. code-block:: python

    >>> import numpy
    >>> 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:

.. code-block:: python

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

Access meta and image data in a Netpbm file:

.. code-block:: python

    >>> 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

Owner

  • Name: Christoph Gohlke
  • Login: cgohlke
  • Kind: user
  • Location: Irvine, California

GitHub Events

Total
  • Push event: 2
  • Create event: 2
Last Year
  • Push event: 2
  • Create event: 2

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 83
  • Total Committers: 1
  • Avg Commits per committer: 83.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 16
  • Committers: 1
  • Avg Commits per committer: 16.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Christoph Gohlke c****e@c****m 83
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 0
  • Average time to close issues: 19 minutes
  • Average time to close pull requests: N/A
  • Total issue authors: 2
  • Total pull request authors: 0
  • Average comments per issue: 1.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Saumya-Gupta-26 (1)
  • jayeye (1)
Pull Request Authors
Top Labels
Issue Labels
question (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 5,689 last-month
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 2
    (may contain duplicates)
  • Total versions: 23
  • Total maintainers: 1
pypi.org: netpbmfile

Read and write Netpbm files

  • Versions: 17
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 5,680 Last month
Rankings
Dependent packages count: 4.8%
Downloads: 8.6%
Average: 16.8%
Stargazers count: 19.3%
Dependent repos count: 21.6%
Forks count: 29.8%
Maintainers (1)
Last synced: 6 months ago
pypi.org: napari-netpbmfile

A napari plugin for reading files via netpbmfile

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 9 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 19.4%
Dependent repos count: 21.6%
Forks count: 29.8%
Average: 32.8%
Downloads: 83.0%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: netpbmfile

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

  • Versions: 4
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent packages count: 28.8%
Dependent repos count: 34.0%
Average: 44.6%
Stargazers count: 54.5%
Forks count: 61.1%
Last synced: 6 months ago

Dependencies

setup.py pypi
  • numpy >=1.19.2