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:
- Organization:
Laboratory for Fluorescence Dynamics, University of California, Irvine
- License:
BSD 3-Clause
- Version:
2020.10.18
Requirements
Matplotlib 3.2 (optional for plotting)
Revisions
- 2020.10.18
Disallow comments after last value in PNM headers.
- 2020.9.18
Remove support for Python 3.6 (NEP 29). Support os.PathLike file names.
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file netpbmfile-2020.10.18.tar.gz
.
File metadata
- Download URL: netpbmfile-2020.10.18.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b6a081e0df62f1f576f9881653a4a00d7eb14f13eb4f260495cbf963a7c990d |
|
MD5 | a4100d48cc68a0569a5a1215fbb4ea5d |
|
BLAKE2b-256 | 6ee1ce8febda00d63b01acd3f6f8b3cd498256c29ff3402aae27c84326ee6ceb |
File details
Details for the file netpbmfile-2020.10.18-py3-none-any.whl
.
File metadata
- Download URL: netpbmfile-2020.10.18-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b3024c77f00418479c010e89008dd4fde6ab3500c1f1247e8e8341991ed7e0e |
|
MD5 | 4588f4013f3363c68345b136f6b27a3c |
|
BLAKE2b-256 | 794ce9dad49b6c62841099e8f0c843bfa82dc9d61f5fc0fff6f728773674db39 |