Skip to main content

generate_xmp

Function generate_xmp 

Source
pub fn generate_xmp(metadata: &GainMapParams, gainmap_length: usize) -> String
Expand description

Generate XMP for a 2-item Primary + GainMap Ultra HDR image.

This single packet goes in the primary JPEG’s APP1 marker. It carries both the numeric metadata (all hdrgm:* attrs) AND the Container:Directory listing.

For maximum compatibility with libultrahdr’s canonical layout (where the primary XMP carries only the directory and the gain-map XMP carries the numbers), use generate_primary_xmp + generate_gainmap_xmp instead.

§Examples

Roundtrip a default set of gain-map parameters:

use zenmeta::xmp::gainmap::{generate_xmp, parse_xmp};

let mut params = zencodec::GainMapParams::default();
for c in &mut params.channels {
    c.max = 2.0;
    c.gamma = 1.0;
}
let xmp = generate_xmp(&params, 5_000);
let (parsed, length) = parse_xmp(&xmp).expect("parse");
assert_eq!(length, Some(5_000));
assert!((parsed.channels[0].max - 2.0).abs() < 1e-5);