
How Ultra HDR JPEGs Work and What Resizing Does to the Gain Map
A sunset photo looks bright on your phone. You resize it for the web, and the exported JPEG still opens, but the highlights look different. One possible cause is that the export dropped the gain map that Ultra HDR uses to render those highlights.
We resized and recompressed two synthetic Ultra HDR JPEGs on a Mac. Exports that saved only the base image lost the gain map. Exports that packaged the map again decoded to HDR. Here is what changed in the files and what to check in your own workflow.
Japanese original published: 2026-12-02
Why an ordinary JPEG viewer can open the file
An Ultra HDR JPEG starts with a standard dynamic range (SDR) base image, followed by a gain map stored as a second JPEG. A conventional JPEG decoder can display the primary image. Compatible software uses the map and its metadata to reconstruct a high dynamic range (HDR) image.
1. Primary JPEG. A conventional viewer can display this SDR base image.
2. Location and rendering metadata. These fields help a decoder find the additional image and interpret its values.
3. Secondary JPEG. The gain map describes adjustments at different positions and can be smaller than the primary image.
HDR rendering. Compatible software uses the gain map and metadata to adjust the base image according to the available display headroom.
Based on the Decode and Display sections of Android Developers: Ultra HDR Image Format v1.1.
Ultra HDR v1 uses the Multi-Picture Format (MPF) to store the additional image. XMP in the primary JPEG identifies the format and helps locate the map. XMP in the secondary JPEG describes how to apply it. ISO 21496-1:2025 separately defines gain map metadata for conversion between image representations. The Android specification describes how one JPEG can carry both kinds of metadata for a single map. Our inputs carried both.
How display headroom changes the result
A gain map expresses how much to adjust the SDR image at each position. The decoder reads each value using metadata such as the gain range and gamma. If the map is smaller than the base image, the decoder interpolates its values at the corresponding positions. This lets it apply a stronger adjustment around a bright window or light source than elsewhere.
The ratio between HDR white and SDR reference white depends on the display and can change with its current operating conditions. With an SDR base image, compatible software adapts the strength of the gain map to that headroom. For example, if the full adjustment for a pixel is a factor of four and the offsets are zero, a weight of 0.5 gives a factor of two in linear light. The weight multiplies the logarithmic gain, so the result is the square root of four. Checking the file and checking the screen are separate steps.
What survived recompression and resizing?
On an Apple silicon Mac, we tested a synthetic landscape with a bright light source and a set of synthetic color tiles. Both used a 1,200 × 800 px base and a 300 × 200 px single-channel gain map. Pillow 11.3.0, with libjpeg-turbo 3.1.1, encoded the base at JPEG quality 92 with 4:2:0 chroma subsampling and the map at quality 90. We combined the images with libultrahdr 1.4.0 and wrote both Ultra HDR v1 and ISO gain map metadata. We set the gain range to 1×–4× in linear light, with gamma 1 and zero SDR and HDR offsets. The quality numbers are encoder settings.
For recompression, we saved the base at quality 80 and 4:2:0. For the smaller version, we resized the base to 600 × 400 px with a Lanczos filter and saved it with the same JPEG settings. In the full-size export with a gain map, we repackaged the original map without re-encoding it. For the smaller export, we resized the map with Lanczos to 150 × 100 px and recompressed it at quality 90. Each pair of outputs used the same compressed base JPEG.
We opened every output with a conventional JPEG reader and checked the MPF, ISO, and XMP markers in the primary image. We then used libultrahdr to locate the secondary JPEG, check its dimensions and metadata, and decode linear HDR output with the decoder’s maximum display boost set to 4×, equivalent to an HDR white level four times the SDR reference white. “Not detected” means the procedure could not retrieve a valid gain map.
Scroll horizontally if the table does not fit.
| Step | Output |
|---|---|
| Input | Base 1200 × 800 px Map 300 × 200 px 42,602 B |
| Exact copy | Base 1200 × 800 px Map 300 × 200 px 42,602 B |
| Re-encode base only | Base 1200 × 800 px Map not detected 27,189 B |
| Re-encode base and add map | Base 1200 × 800 px Map 300 × 200 px 32,754 B |
| Resize base only | Base 600 × 400 px Map not detected 9,823 B |
| Resize both | Base 600 × 400 px Map 150 × 100 px 13,512 B |
| Re-encode and copy XMP only | Base 1200 × 800 px Map not detected 28,144 B |
NanToo measurements. We checked the outputs with GitHub: google/libultrahdr at v1.4.0.
Scroll horizontally if the table does not fit.
| Step | Output |
|---|---|
| Input | Base 1200 × 800 px Map 300 × 200 px 25,664 B |
| Exact copy | Base 1200 × 800 px Map 300 × 200 px 25,664 B |
| Re-encode base only | Base 1200 × 800 px Map not detected 18,304 B |
| Re-encode base and add map | Base 1200 × 800 px Map 300 × 200 px 23,050 B |
| Resize base only | Base 600 × 400 px Map not detected 7,505 B |
| Resize both | Base 600 × 400 px Map 150 × 100 px 11,244 B |
| Re-encode and copy XMP only | Base 1200 × 800 px Map not detected 19,259 B |
NanToo measurements. We checked the outputs with GitHub: google/libultrahdr at v1.4.0.
Both samples use a scale from 0 to 45,000 B.
Landscape with a bright light source
Input 42,602 B (map present)
Recompress base only 27,189 B (no map)
Recompress base and repackage map 32,754 B (map present)
Halve base dimensions 9,823 B (no map)
Halve dimensions of both images 13,512 B (map present)
Color tiles
Input 25,664 B (map present)
Recompress base only 18,304 B (no map)
Recompress base and repackage map 23,050 B (map present)
Halve base dimensions 7,505 B (no map)
Halve dimensions of both images 11,244 B (map present)
NanToo measurements. Blue indicates a file with a gain map. Gray indicates a base-only file.
Rewriting the base alone removed the map from both samples. Copying only the primary XMP preserved the identifying information but left out the secondary JPEG it referred to. When we halved both image dimensions, adding the map increased the total file size. The landscape with a bright light source went from 9,823 B to 13,512 B, and the color tiles went from 7,505 B to 11,244 B. The difference includes the map, packaging metadata, and an ICC profile supplied by the reference codec. The byte-for-byte copies matched the input SHA-256 hashes. These measurements show what happened in the tested export paths. File sizes will vary with the image and encoder. Display luminance and image quality were outside the scope of the test.
How to keep HDR when archiving or editing
To archive an original, copy the file as-is. Opening it and saving a new JPEG introduces an export step that may retain only the base image. The .jpg extension and the ability to open the file in an older viewer tell you little about whether the map survived.
When cropping, rotating, or resizing, apply matching geometry to both images so the gain map stays aligned with the base, even when they have different resolutions. Our resizing test establishes that the result still contains a decodable map. Interpolating the map and the base separately can give a different result from resizing the reconstructed HDR image, particularly along sharp brightness edges. For substantial exposure or color changes, export with software that can manage both the SDR and HDR renderings. Regenerate the map when needed and check both renderings.
If you remove location data before sharing, verify the exported file for both location data and gain map retention. A broad metadata removal option can behave differently from a tool that removes selected Exif fields.
Check the image the browser actually receives
Check the original first, then download the file your image service or CDN delivers. With srcset, use developer tools to find the image the browser selected and test the smaller derivatives too. A CDN can serve a plain JPEG even when the master file still has its gain map.
- Check with a gain-map-aware decoder that the auxiliary image and metadata are present and decode successfully.
- Review highlights in the browser or app on a compatible HDR display. Check tones and visible detail in the SDR base image on an ordinary display as well.
- Verify each width you deliver. If you deliberately serve SDR for some views, choose the quality and file size based on that SDR rendering.
For a portfolio or product page, you might keep HDR for the large detail view and use SDR for previews and thumbnails. Decide where the extra range matters, then test the corresponding files end to end.
References and sources
- Android Developers: Ultra HDR Image Format v1.1 ↗(The SDR base image, the secondary JPEG, XMP and MPF, rendering math, and ISO 21496-1 compatibility.)
- ISO: ISO 21496-1:2025 — Digital photography — Gain map metadata for image conversion — Part 1: Dynamic range conversion ↗(ISO's public bibliographic record and abstract. The full standard is sold separately.)
- Android Developers: Support Ultra HDR ↗(Display on supported devices, image capture, and gain map detection.)
- Apple Developer: Use HDR for dynamic image experiences in your app ↗(WWDC24 session on display headroom, Adaptive HDR, and the Apple frameworks.)
- GitHub: google/libultrahdr at v1.4.0 ↗(The reference codec release used in the experiment, including its build options and sample app.)
- Pillow: Image file formats ↗(The JPEG quality, chroma subsampling, and XMP options in Pillow 11.3.0.)
Editorial note
This article was prepared with AI assistance and reviewed by an editor before publication. It may still contain factual errors, interpretation mistakes, or outdated information. Check the cited primary sources or official documentation before making an important decision.

