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 grayscale, read-only)
PF (float32 RGB, read-only)
PF4 (float32 RGBA, read-only)
PGX (signed grayscale, read-only)
No gamma correction is performed. Only one image per file is supported.
The PGX format is specified in ITU-T Rec. T.803.
- Author:
- License:
BSD 3-Clause
- Version:
2022.9.12
Requirements
This release has been tested with the following requirements and dependencies (other versions may work):
Revisions
2022.9.12
Allow space after token value in PAM.
Update metadata.
2022.2.2
Add type hints.
Support reading PF4 RGBA FloatMaps.
Drop support for Python 3.7 and numpy < 1.19 (NEP29).
2021.6.6
Fix unclosed file warnings.
Support reading PGX JPEG2000 reference images.
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 reading 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'
View the image stored in a Netpbm file from a command line:
python -m netpbmfile _tmp.pgm
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-2022.9.12.tar.gz
.
File metadata
- Download URL: netpbmfile-2022.9.12.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dbb369709febf045d995ba0a9b5eac2c64fe7432cc8f2f00fea7c4336c6a4bb |
|
MD5 | c8ae65a41c924ec1876be9aeb8e6aa97 |
|
BLAKE2b-256 | 00e97b0319e18e3b476f2be378ad05ec8071e015477747d474277a1a7e1d40be |
File details
Details for the file netpbmfile-2022.9.12-py3-none-any.whl
.
File metadata
- Download URL: netpbmfile-2022.9.12-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fce186f072a36a859b41ad7603a304b1851551ecd684f82974e80b27ac91bcff |
|
MD5 | fc70c72ab79c09c28bb91390262719ee |
|
BLAKE2b-256 | b74346a1de62e8e10e53f12355978279021bdc8da2c8acbd71cc691d8e616d4a |