Skip to main content

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 float32 RAW (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:

  1. Prepare a 2D NumPy array of shape (height, width) with dtype uint16 (or float32).
  2. Build a numpy2dng.dng.DNGTags instance and set at least:
    • Tag.ImageWidth, Tag.ImageLength, Tag.BitsPerSample
  3. Convert and write a .dng using numpy2dng.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 → DNG
  • numpy2dng.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


Download files

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

Source Distribution

numpy2dng-0.1.0.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numpy2dng-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

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

Hashes for numpy2dng-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d92dc9198adefd3995e94ceb760acb609222543324af982274cf7cf7ebfcf9ec
MD5 84ca1d27064331c30f6ccfd82046b677
BLAKE2b-256 40234d71109e9834a99048118df59e9ca71c42f0da4fa99fae1c8ef71d250a40

See more details on using hashes here.

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

Hashes for numpy2dng-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b861d27469993b35bc5805523f7f0b2f37e045fd4b73be319f7d2cee4e5c180
MD5 4c446fe5521b879956a32f4b93304cfb
BLAKE2b-256 bc7c748ea5c7a42bb5a782c1db3963d667740407bac9be5b5cb3e9bd4760dd00

See more details on using hashes here.

Supported by

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