justPFM
Read and write Portable Float Map (PFM) images as NumPy arrays—from files or bytes.
Benchmark badges: 1.2.0, 2026-09-18, 2048² RGB float32 (48 MiB), scale 1,
native byte order, contiguous write input; Linux / Ryzen 9 7940HS, warm cache,
no fsync. Measurements and methodology.
Coverage badge shows the enforced gate, not a live measurement.
At a glance
- Grayscale and RGB float32 images, with both byte orders and strided arrays.
- File I/O plus in-memory encoding and decoding; NumPy is the only runtime dependency.
- Atomic file replacement and validated input, with an optional read-size limit.
- Python 3.7–3.14, type annotations, and MIT license.
Install
python -m pip install justpfm
Quick start
import numpy as np
from justpfm import decode_pfm, encode_pfm, read_pfm, write_pfm
pixels = np.arange(15, dtype=np.float32).reshape(3, 5)
# Files: string paths and pathlib.Path are supported.
write_pfm("image.pfm", pixels)
loaded = read_pfm("image.pfm", max_pixels=4_000_000)
print(loaded.shape) # (3, 5, 1)
# Bytes: useful with your own HTTP, archive, or cloud-storage code.
payload = encode_pfm(pixels)
restored = decode_pfm(payload, max_pixels=4_000_000)
| Function | Purpose |
|---|---|
write_pfm(file_name, data, scale=1) |
Save an array to a file. |
read_pfm(file_name, *, max_pixels=None) |
Load an array from a file. |
encode_pfm(data, scale=1) |
Encode an array to PFM bytes. |
decode_pfm(payload, *, max_pixels=None) |
Decode PFM bytes or bytearray. |
Inputs must be float32 arrays shaped (H, W), (H, W, 1), or (H, W, 3).
Reads return top-first (H, W, C) arrays; use loaded[..., 0] for 2D grayscale.
For native byte order and contiguous storage, use
np.ascontiguousarray(loaded, dtype=np.float32).
Use the default scale=1 to preserve values. Other positive finite scales are
recorded on write and multiplied into pixels on read. max_pixels limits
H * W before pixel allocation; its default is unlimited. In-memory APIs hold
the full PFM payload, and decoding returns writable pixels independent of it.
Learn more
- API reference: validation, scaling, array layout, memory, and file permissions.
- Benchmarks: raw results, reproduction, and performance tradeoffs.
- Compatibility and changelog.
- Contributing: setup, commit hooks, tests, coverage, and releases.
Metadata
Release files for justpfm 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| justpfm-1.2.1.tar.gz | 36.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| justpfm-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.6 kB
Release files / justpfm-1.2.1.tar.gz
| Download URL | justpfm-1.2.1.tar.gz |
|---|---|
| Size | 36.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37b6b64c145b9c8ae9d15fbd8d44d480410dc70df508d0e7159397ec24bc590b
|
|
BLAKE2b-256 checksum How to use checksums |
75f8ced8c77dd99b37b5a491cecaad34c4e90d81a5f0562149a7c9e46c07e2a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / justpfm-1.2.1-py3-none-any.whl
| Download URL | justpfm-1.2.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd5aac5dde1fc95583dc01d3683a2839459750041a0c610a6e9da6bab9efc273
|
|
BLAKE2b-256 checksum How to use checksums |
8be7457018b0304a071274a97d2ca4955c12dc0107929692c287548254958fef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|