Skip to main content

muraw logo

muraw

License

Python library for reading, writing, and rendering Adobe DNG (Digital Negative) raw image files. Provides both a comprehensive Python API and command-line tools for DNG manipulation, rendering, metadata handling, and multi-threaded batch processing. Performance-critical operations are implemented in C/C++ extensions, but this initial (May 1, 2026) release prioritizes rendering correctness over speed optimization.

Key Features

  • DNG Read/Write: Full support for reading, writing, and modifying Adobe DNG (Digital Negative) files.
  • RAW Rendering Pipeline: Complete implementation of DNG rendering pipeline (linearization, demosaicing, opcodes, color correction, tone curves). On macOS can opt between built-in renderer and Core Image renderer.
  • Multiple Demosaicing Algorithms: BILINEAR, EA, EA_FAST, OPENCV_EA, and VNG and RCD with the optional muraw-demosaic package
  • XMP Support: Renderer supports Temperature, Tint, Exposure, Curves, and radial distortion from XMP metadata.
  • Metadata Handling: User-friendly TIFF/EXIF/XMP tag handling with automatic type conversion
  • Compression: Uncompressed, JPEG, JPEG XL support with multi-core parallel compression for tiled formats
  • CLI Tools: Comprehensive command-line interface for DNG operations.
  • Batch Processing: Multi-threaded batch conversion and video encoding.

Installation

From PyPI

pip install muraw

Or in pyproject.toml:

[project]
dependencies = [
    "muraw",
]

Optional Dependencies

Video Encoding & Google Photos: For video encoding and Google Photos integration:

pip install "muraw[all]"

Core Image (macOS): For macOS users, installing the Core Image dependency enables a second rendering engine that will be available at runtime alongside the built-in renderer:

pip install "muraw[coreimage]"

Combined: To install all optional features:

pip install "muraw[all,coreimage]"

Or in pyproject.toml:

[project]
dependencies = [
    "muraw[all,coreimage]",
]

From GitHub

To install the latest development version directly from GitHub:

[project]
dependencies = [
    "muraw @ git+https://github.com/mu-files/mufusion.git#subdirectory=muraw",
]

For Local Development

Clone the repository and install the package in editable mode:

git clone https://github.com/mu-files/mufusion.git
cd mufusion/muraw
pip install -e ../mufusion -e .

Note: muraw is pure Python and compiles nothing. The VNG and RCD demosaic algorithms are C extensions in the separate muraw-demosaic package, which is built from source and is not on PyPI. Install it only to use those two algorithms, into the same environment as muraw. It needs a C compiler. For VNG:

pip install "muraw-demosaic @ git+https://github.com/mu-files/mufusion.git#subdirectory=muraw-demosaic"

From a clone of the repository, pip install ./muraw-demosaic does the same. RCD needs a source edit before that install; see the muraw-demosaic README.

API Overview

Core Classes

DngFile: Subclass of TiffFile for reading DNG files. Provides access to IFDs (Image File Directories), metadata, and raw image data.

DngPage: Subclass of TiffPage representing a single IFD within a DNG file. Can be a raw CFA page, LinearRaw RGB page, or preview/thumbnail. Provides methods to extract raw data at various pipeline stages and render to display-referred RGB.

MetadataTags: Container for TIFF/EXIF/DNG tags with type-safe tag handling.

Reading DNGs

Opening and navigating: DngFile(path) opens a DNG file. Use ifd0 property to access IFD0, get_main_page() to get the primary raw image, or get_flattened_pages() to access all IFDs including SubIFDs.

Extracting raw data: DngPage.get_cfa() extracts CFA (Color Filter Array) data at various pipeline stages (raw, linearized, post-opcodes). DngPage.get_linear_raw() extracts LinearRaw RGB data.

Rendering to RGB: DngPage.render() applies the full DNG rendering pipeline (demosaicing, opcodes, color correction, tone curves, etc.) to produce display-referred RGB. The scale parameter allows for fast preview renders at reduced resolution. decode_dng() is a convenience function that handles file opening and rendering in one call.

Metadata access: DngPage.get_tag(name) retrieves TIFF/DNG tags with automatic type conversion (e.g., get_tag("ColorMatrix1") returns a 3×3 NumPy array).

Writing DNGs

PageEncoding: Dataclass that groups compression type and codec-specific arguments. Used to specify how image data should be compressed when -writing DNGs from an array or -transcoding a DNG page. For JXL compression, compression_args=None defaults to lossless (distance=0.0, effort=4). Example: PageEncoding(compression=COMPRESSION.JPEGXL_DNG, compression_args={'distance': 0.5, 'effort': 7}).

write_dng(): The most general function to create a DNG file. Takes an IFD0 spec and optional list of SubIFD specs (each can be IfdPageSpec or IfdDataSpec). Each spec describes the page data and how to encode it.

write_dng_from_page(): Create a DNG from an existing DngPage or IfdPageSpec. Supports transformations (scaling, demosaicing), compression transcoding (e.g., uncompressed to JXL via transcode_encoding=PageEncoding(...)), preview/pyramid generation, and tag manipulation.

write_dng_from_array(): Create a DNG from an IfdDataSpec containing a NumPy raw pixel data array and metadata. Supports preview and pyramid generation with optional compression via encoding=PageEncoding(...).

Batch Processing

Pipeline control: ProcessingPipeline class provides fine-grained control over batch processing with customizable producer/consumer/writer stages that decouple file I/O operations from pixel processing (e.g., decouple reading DngFile from disk and rendering it).

Image sequences: ImageSequencePipeline is a ProcessingPipeline for processing sequences of image files and saving the results (.tiff/.jpg) to an output folder.

Video encoding: VideoEncodePipeline is a ProcessingPipeline for encoding image sequences to video files with configurable codecs, resolution, and frame rates, and saving the result to a video file (.mp4). Requires pip install muraw[all].

Parallelism: Control parallelism with --num-workers flag in CLI or num_workers parameter in API. Default is 4 workers. Adjust based on CPU cores and memory availability.

Metadata

Tag management: MetadataTags.add_tag() adds TIFF/EXIF tags with automatic type handling. DngPage.get_page_tags() returns a MetadataTags object with metadata for that page.

Type registry: TIFF_TAG_TYPE_REGISTRY provides metadata about all supported TIFF/DNG tags, including data types, valid IFDs, and enum mappings.

CLI Commands

The muraw command provides comprehensive DNG operations:

Image Format Conversion

# Convert any image format to another
muraw convert-image input.tif output.jpg

DNG Metadata

Display and filter DNG metadata:

# Show all metadata for all IFDs
muraw dng metadata input.dng

# Show specific IFD
muraw dng metadata input.dng --ifd 0

# Filter tags by pattern
muraw dng metadata input.dng --tag "Color.*" --tag "Exposure"

# Exclude tags
muraw dng metadata input.dng --exclude-tag "XMP"

# Summary only
muraw dng metadata input.dng --summary

DNG Raw Stage Extraction

Extract raw data at specific pipeline stages:

# Extract unprocessed raw data
muraw dng raw-stage input.dng output.tif raw

# Extract after OpcodeList2
muraw dng raw-stage input.dng output.tif linearized-plus-ops

# Extract demosaiced camera RGB (VNG and RCD are choices only with muraw-demosaic)
muraw dng raw-stage input.dng output.tif camera-rgb --demosaic EA

# Extract from specific IFD
muraw dng raw-stage input.dng output.tif linearized --ifd subifd2

DNG Copy and Transform

Create a new DNG from source DNG with optional transformations:

# Create a new DNG file with the main page transcoded to JXL
muraw dng copy input.dng output.dng --jxl-distance 0.5

# Scale and demosaic
muraw dng copy input.dng output.dng --scale 0.5 --demosaic

# Generate preview (1/4 scale)
muraw dng copy input.dng output.dng --preview --preview-reduce 4

# Generate preview (1/2 scale)
muraw dng copy input.dng output.dng --preview --preview-reduce 2

# Strip tags
muraw dng copy input.dng output.dng --strip-tag OpcodeList2,OpcodeList3

# Add/override tags
muraw dng copy input.dng output.dng --tag "Artist=John Doe" --tag "Copyright=2026"

# Generate raw "preview" pyramid levels
muraw dng copy input.dng output.dng --pyramid-levels 3

DNG Rendering

Convert DNG to display image with adjustments:

# Basic conversion
muraw dng convert input.dng output.jpg

# With white balance and exposure
muraw dng convert input.dng output.tif --temperature 5500 --tint 10 --exposure 0.5

# 16-bit output
muraw dng convert input.dng output.tif --bit-depth 16

# Use Core Image on macOS
muraw dng convert input.dng output.jpg --use-coreimage

# Convert specific IFD
muraw dng convert input.dng output.jpg --ifd subifd1

Batch DNG Conversion

Process multiple DNGs in parallel:

# Convert folder of DNGs to TIFF
muraw dng batch-convert /path/to/dngs/ /path/to/output/ --format tif

# Control parallelism (set to 8 here, default is 4 workers)
muraw dng batch-convert /path/to/dngs/ /path/to/output/ --format tif --num-workers 8

# Use fixed rendering parameters for each image
muraw dng batch-convert /path/to/dngs/ /path/to/output/ \
  --format jxl --temperature 5500 --exposure 0.5

# From CSV with per-file settings
# CSV format: filename,Temperature,Tint,Exposure2012,orientation
muraw dng batch-convert settings.csv /path/to/output/ --format tif

# Scaled output (uses the efficient scaling rendering path)
muraw dng batch-convert /path/to/dngs/ /path/to/output/ --scale 0.5

Batch DNG to Video

Requires: pip install muraw[all] (for video encoding support)

Create video from DNG sequence:

# Basic video creation
muraw dng batch-to-video /path/to/dngs/ output.mp4

# With rendering and encoding options
muraw dng batch-to-video /path/to/dngs/ output.mp4 \
  --resolution 1920x1080 --codec hevc --crf 20 --bit-depth 10 \
  --temperature 5500 --exposure 0.5 --frame-rate 30

# Timelapse (1 frame every 2 seconds)
muraw dng batch-to-video /path/to/dngs/ timelapse.mp4 --frame-rate 0.5

# With filename overlay
muraw dng batch-to-video /path/to/dngs/ output.mp4 --overlay-txt

# From CSV with per-file settings
muraw dng batch-to-video settings.csv output.mp4 --resolution 1920x1080

Google Photos Integration

Requires: pip install muraw[all] (for Google Photos support)

Upload images to Google Photos:

# Authenticate
muraw google-photos auth --credentials credentials.json

# Upload image
muraw google-photos upload image.jpg --album "My Album"

# List albums
muraw google-photos list-albums

Examples

make_test_dng.py

Creates size-constrained test DNG files by iteratively scaling down the image resolution until it fits within a target size. All test files were generated using this code.

python examples/make_test_dng.py input.dng output.dng --target-size 1048576
python examples/make_test_dng.py input.dng output.dng --target-size 1048576 --generate-preview

Features:

  • Iterative scaling by powers of 2 until target size is met
  • Demosaics to LINEAR_RAW in order to scale image
  • Optional JXL compression

Tests

The test suite covers DNG reading, writing, rendering, metadata handling, and CLI operations.

Running Tests

Requires: pip install muraw[all] (pytest is included in the [all] extra)

cd /path/to/mufusion/muraw
venv/bin/pytest tests/

Run specific test file:

venv/bin/pytest tests/test_dng_render.py -v

Run with detailed logging:

venv/bin/pytest tests/test_cli.py -v -s --log-cli-level=INFO

Test Categories

Note: Many tests validate results against Adobe's dng_validate tool from the DNG SDK. To use this validation:

  1. Download DNG SDK from: https://helpx.adobe.com/camera-raw/digital-negative.html
  2. Build the dng_validate tool (see SDK documentation)
  3. Place the binary at the path specified in tests/conftest.py or update DNG_VALIDATE_PATH

Tests always use muraw's built-in validator.

Note: Test image files (~80 MB) are stored in a separate repository (mu-files/mu-image-testdata) and are automatically downloaded on the first test run.

DNG Rendering (test_dng_render.py): Tests the full rendering pipeline, including linearization, demosaicing, color correction, tone curves, and output color space conversion for a variety of real camera DNG files (scaled to download-friendly resolution) and compares results against dng_validate.

Metadata Handling (test_metadata_*.py): Tests TIFF tag reading/writing, endianness handling, XMP parsing, and Core Graphics metadata extraction on macOS.

Write Operations (test_write_dng*.py): Tests DNG creation from arrays, page copying, compression options, and tag manipulation.

Roundtrip Tests (test_*_roundtrip.py): Tests that read-modify-write operations preserve data correctly (color temperature, SubIFD structure).

CLI Commands (test_cli.py): Tests command-line interface functionality.

Preview and Pyramid (test_preview_rendering.py, test_pyramid_subifd.py): Tests thumbnail/preview generation and pyramid-level creation.

Demosaicing (test_demosaic.py): Tests various demosaicing algorithms.

Known Issues

Not Implemented

The following DNG features are not yet implemented:

  • Triple-illuminant: Support for 3 calibration illuminants (ColorMatrix3, CalibrationIlluminant3)
  • RGBTables: DNG version 1.6+ per-channel 1D LUTs
  • ReductionMatrix: Support for cameras with >3 color channels
  • SemanticMasks: DNG v1.6+ depth maps and segmentation masks
  • HDR/Overrange: ProfileDynamicRange and extended dynamic range support

Performance Notes

Demosaicing Algorithms: muraw includes several demosaicing algorithms with different quality/speed tradeoffs:

  • BILINEAR: Good quality, fast (default for most operations)
  • VNG (needs muraw-demosaic): High quality, slower
  • EA: Hamilton–Adams (default for convert / camera RGB)
  • EA_FAST: Single-pass axis-pick green + bilinear chroma; faster, lower quality
  • OPENCV_EA: OpenCV edge-aware demosaic (comparison / visualization only)
  • RCD (needs muraw-demosaic built with RCD, GPL-licensed): High quality, slower

VNG and RCD are C extensions in the separate muraw-demosaic package, which you build from source. RCD is licensed under GPL v3, which is separate from muraw's BSD-3-Clause license, so muraw-demosaic builds it only once it is enabled; its README says how.

Core Image Rendering: On macOS, Core Image provides native DNG rendering. Use --use-coreimage flag in CLI or use_coreimage_if_available=True in API.

License

This software is released under the BSD 3-Clause License. See LICENSE for full terms.

VNG (CDDL 1.0) and RCD (GPL v3) are not part of muraw; they are in the optional muraw-demosaic package, under their own licenses.

Metadata

Release files for muraw 0.1.20261116.1011

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for muraw 0.1.20261116.1011
File Size Uploaded Provenance Actions
muraw-0.1.20261116.1011.tar.gz 172.4 kB With provenance Details for muraw-0.1.20261116.1011.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for muraw 0.1.20261116.1011
File Interpreter ABI Platform Actions
muraw-0.1.20261116.1011-py3-none-any.whl Python 3 none any Details for muraw-0.1.20261116.1011-py3-none-any.whl

Total release size: 338.2 kB

Release files / muraw-0.1.20261116.1011.tar.gz

Download URL muraw-0.1.20261116.1011.tar.gz
Size 172.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d269dd9a65ee9b481b2b17b3651d1a2506402639e40c261be885358149dad189
BLAKE2b-256 checksum
How to use checksums
449757deb0928aacaf3458a82aefa08fc142b170f2e737fa60dc95e815fa56a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / muraw-0.1.20261116.1011-py3-none-any.whl

Download URL muraw-0.1.20261116.1011-py3-none-any.whl
Size 165.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e5ef533f920df9857793d88a02239fa252abd6bf8ce2697cd2a477d10e57716
BLAKE2b-256 checksum
How to use checksums
288640142f3a947b03c123ad6ce0649c3a6fcf7e7193d776c0a6c49b118bec0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for muraw 0.1.20261116.1011

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for muraw-0.1.20261116.1011.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page