Skip to main content

Read and write Netpbm files

Project description

Netpbmfile is a Python library to read and write image files in the Netpbm format as specified at http://netpbm.sourceforge.net/doc/.

The following Netpbm and Portable FloatMap formats are supported:

  • PBM (bi-level)

  • PGM (grayscale)

  • PPM (color)

  • PAM (arbitrary)

  • XV thumbnail (RGB332, read-only)

  • PF (float32 RGB, read-only)

  • Pf (float32 grayscale, read-only)

No gamma correction is performed. Only one image per file is supported.

Author:

Christoph Gohlke

Organization:

Laboratory for Fluorescence Dynamics, University of California, Irvine

License:

BSD 3-Clause

Version:

2020.1.1

Requirements

Revisions

2020.1.1

Fix reading tightly packed P1 format and ASCII data with inline comments. Remove support for Python 2.7 and 3.5. Update copyright.

2018.10.18

Move netpbmfile.py into netpbmfile package.

2018.02.18

Support Portable FloatMaps. Style fixes.

2016.02.24

Use ‘fromdata’ classmethod to initialize from data. Support ‘with’ statement. Scale RGB images to maxval for display. Make keyword arguments explicit. Support numpy 1.10.

Examples

Save a numpy array to a Netpbm file in grayscale format:

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

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

>>> image = imread('_tmp.pgm')
>>> assert numpy.all(image == data)

Access meta and image data in a Netpbm file:

>>> with NetpbmFile('_tmp.pgm') as pgm:
...     pgm.axes
...     pgm.shape
...     pgm.dtype
...     pgm.maxval
...     pgm.magicnum
...     image = pgm.asarray()
'YX'
(2, 2)
dtype('>u2')
65535
b'P5'

Project details


Download files

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

Source Distribution

netpbmfile-2020.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

netpbmfile-2020.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file netpbmfile-2020.1.1.tar.gz.

File metadata

  • Download URL: netpbmfile-2020.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for netpbmfile-2020.1.1.tar.gz
Algorithm Hash digest
SHA256 87369fa1c6d61624af6a9fc55885314314c8418b4d376ce8f0a2faedc802fbb3
MD5 00bf39d29312396ac41d263faa5040e8
BLAKE2b-256 13634176c467b22907a4f7e39dd3e8afcc72e90a049865dad7c1dafa3f936d9f

See more details on using hashes here.

File details

Details for the file netpbmfile-2020.1.1-py3-none-any.whl.

File metadata

  • Download URL: netpbmfile-2020.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for netpbmfile-2020.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b2db2b6807c73ec6cb0afb6a42d97268969d60e8bb117c3cc799a40f5183340
MD5 a2bbabe6dca67526a95750c0af34575f
BLAKE2b-256 b64a8f6237e3e848fdd3b812c2c6ddafd4df3c6bbe71efede020ca7e2a1eaa22

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page