Pure Python utility for creating DNG files from numpy arrays.
Project description
numpy2dng
Pure Python utility for creating Adobe DNG files from RAW image data stored in NumPy arrays.
This project is a refactor of the original PiDNG library, focused on a smaller, cleaner core and modern packaging.
Requirements
- Python 3.10+
- NumPy 2.0+
Features
- Pure Python (no C extensions)
- Uncompressed DNG output
- Supports 8/10/12/14/16-bit integer RAW (via packing for 10/12/14-bit)
- Supports
float32RAW (writes DNG 1.4-compatible files) - “Safe packing” for 10/12/14-bit data with any image width (no special alignment required)
Non-goals / Limitations
- Not a full RAW pipeline (no demosaic, no color processing)
- Does not auto-detect camera metadata; you must provide the required DNG/TIFF tags
- No JPEG/LJ92 compression (uncompressed only)
Installation
Using uv (recommended):
uv add numpy2dng
Using pip:
pip install numpy2dng
Usage
Typical flow:
- Prepare a 2D NumPy array of shape
(height, width)with dtypeuint16(orfloat32). - Build a
numpy2dng.dng.DNGTagsinstance and set at least:Tag.ImageWidth,Tag.ImageLength,Tag.BitsPerSample
- Convert and write a
.dngusingnumpy2dng.core.RAW2DNG.
For performance-sensitive workflows, RAW2DNG.convert(..., file=...) can write directly to an open binary file handle (avoids an extra copy).
API Overview
numpy2dng.core.RAW2DNG: main converter for NumPy arrays → DNGnumpy2dng.dng.DNGTags/numpy2dng.dng.Tag: tag container and tag definitions
Development
uv sync
uv run pytest
uv run ruff check .
Credits
Based on (and inspired by) PiDNG
Future work
- Add more metadata tags and convenience methods for common camera models
- Support for additional data types and compression methods
- Improve documentation and add usage examples
License
Same as PiDNG: MIT License. See LICENSE file for details.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numpy2dng-0.1.0.tar.gz.
File metadata
- Download URL: numpy2dng-0.1.0.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d92dc9198adefd3995e94ceb760acb609222543324af982274cf7cf7ebfcf9ec
|
|
| MD5 |
84ca1d27064331c30f6ccfd82046b677
|
|
| BLAKE2b-256 |
40234d71109e9834a99048118df59e9ca71c42f0da4fa99fae1c8ef71d250a40
|
File details
Details for the file numpy2dng-0.1.0-py3-none-any.whl.
File metadata
- Download URL: numpy2dng-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b861d27469993b35bc5805523f7f0b2f37e045fd4b73be319f7d2cee4e5c180
|
|
| MD5 |
4c446fe5521b879956a32f4b93304cfb
|
|
| BLAKE2b-256 |
bc7c748ea5c7a42bb5a782c1db3963d667740407bac9be5b5cb3e9bd4760dd00
|