Can JPEG Files Embed Gain Maps for HDR?
Standard JPEG files can embed gain maps to emulate the high dynamic range (HDR) capabilities of newer formats while remaining universally backward-compatible. By packaging an auxiliary gain map image and mathematical metadata alongside a traditional standard dynamic range (SDR) photo, devices can dynamically reconstruct an HDR image on compatible screens without breaking viewing compatibility on legacy displays.
How Gain Maps Function in Legacy JPEGs
A standard JPEG is limited to 8-bit color depth per channel and uses standard SDR transfer functions (such as sRGB). To overcome these physical constraints, modern imaging pipelines use a dual-layer approach:
- The Base Image: A standard 8-bit SDR JPEG file that any legacy viewer, browser, or operating system can decode and display normally.
- The Gain Map: A secondary, highly compressed grayscale or color map stored within the file's metadata segments (such as APP2 or APP11 markers) using formats like Adobe XMP and Multi-Picture Format (MPF).
- Metadata Parameters: Instructions detailing how to mathematically combine the base image and the gain map, defining parameters like minimum/maximum headroom, gamma, and color space offsets.
When an HDR-capable application loads the file, it reads the metadata, calculates the display's current brightness headroom, and blends the gain map over the base SDR image to illuminate highlights and expand shadow detail. If the software or screen does not support HDR, it simply ignores the auxiliary metadata and displays the SDR base layer.
Standardization and Modern Implementations
Historically, camera manufacturers and software vendors used proprietary methods to store gain maps. Today, the technology has consolidated around open specifications:
- Google Ultra HDR: Introduced in Android 14, Ultra HDR utilizes standard JPEG containers carrying an auxiliary gain map via MPF and XMP metadata.
- ISO 21496-1: Standardized by the International Organization for Standardization, this specification defines a universal metadata format for gain maps, ensuring cross-platform interoperability between Android, Apple ecosystems, and web browsers like Chromium.
Advantages Over Native Next-Gen HDR Formats
Modern formats like AVIF, HEIC, and JPEG XL support native 10-bit and 12-bit color profiles (such as HDR10 and HLG). While technically superior in compression efficiency, they face two major hurdles that gain map JPEGs successfully navigate:
- Graceful Tone Mapping: Direct HDR-to-SDR tone mapping often results in clipped highlights, dull colors, or unpredictable rendering on standard displays. The embedded gain map approach guarantees that the creator's exact SDR intent is preserved on non-HDR screens.
- Universal Compatibility: Billions of legacy devices and websites cannot decode newer formats. A JPEG with an embedded gain map functions everywhere, rendering immediately on legacy systems while scaling up dynamically on high-nit smartphone, tablet, and monitor screens.