Expand description
Ultra HDR - Pure Rust encoder/decoder for HDR images with gain maps.
Ultra HDR is an image format that stores HDR (High Dynamic Range) content in a backwards-compatible JPEG file. Legacy viewers see the SDR (Standard Dynamic Range) base image, while HDR-capable displays can reconstruct the full HDR content using an embedded gain map.
§Crate Structure
ultrahdr_core- Core gain map math and metadata (no codec dependency)ultrahdr(this crate) - Full encoder/decoder with jpegli integration
§Format Overview
An Ultra HDR JPEG contains:
- Primary JPEG: SDR base image (8-bit, sRGB)
- Gain map JPEG: Compressed ratio of HDR/SDR luminance
- XMP metadata: Describes how to apply the gain map
- MPF header: Multi-Picture Format container
§Example
ⓘ
use ultrahdr::{Encoder, Decoder, RawImage, PixelFormat, ColorTransfer};
// Encoding HDR to Ultra HDR JPEG
let hdr_image = RawImage::from_data(
1920, 1080,
PixelFormat::Rgba16F,
ColorGamut::Bt2100,
ColorTransfer::Pq,
hdr_pixels,
)?;
let ultrahdr_jpeg = Encoder::new()
.set_hdr_image(hdr_image)
.set_quality(90, 85)
.encode()?;
// Decoding Ultra HDR JPEG
let decoder = Decoder::new(&ultrahdr_jpeg)?;
let hdr_output = decoder.decode_hdr(4.0)?; // 4x SDR brightness§Standards
This implementation follows:
- Ultra HDR Image Format v1.1
- ISO 21496-1 (gain map metadata)
- Adobe XMP (hdrgm namespace)
Modules§
- color
- Color space handling: transfer functions, gamut matrices, conversions.
- container
- JPEG container utilities for codec-agnostic Ultra HDR support.
- gainmap
- Gain map computation and application.
- jpeg
- JPEG handling utilities.
- limits
- Safety limits for parsing and allocation.
- luminance
- Reference display luminance values (in nits).
- metadata
- Metadata handling for Ultra HDR images.
Structs§
- Decoder
- Ultra HDR decoder.
- Encoder
- Ultra HDR encoder.
- Fraction
- A fraction for ISO 21496-1 metadata encoding.
- GainMap
- A gain map image (8-bit grayscale or per-channel).
- Gain
MapConfig - Configuration for gain map computation.
- Gain
MapMetadata - Gain map metadata (linear scale values). These values describe how to interpret the gain map.
- RawImage
- A raw (uncompressed) image.
- Unstoppable
- A
Stopimplementation that never stops (no cooperative cancellation).
Enums§
- Color
Gamut - Color gamut / color space primaries.
- Color
Transfer - Electro-optical transfer function (EOTF/OETF).
- Error
- Errors that can occur during Ultra HDR operations.
- HdrOutput
Format - Output format for HDR reconstruction.
- Pixel
Format - Pixel format for raw images.
- Stop
Reason - Why an operation was stopped.
Traits§
- Stop
- Cooperative cancellation check.
Type Aliases§
- Result
- Result type for Ultra HDR operations.