DEV Community

Albert Zeyer
Albert Zeyer

Posted on

Playing around with Ultra HDR

This is the ultrahdr.py script, which generates this HDR-demo.

(Check gregbenzphotography.com/hdr/ whether you can display HDR properly.)

High-dynamic range (HDR) is to extend the usual color range (Standard Dynamic Range (SDR)) and usually also extends the common 8bit color depth to 10bit or more.

Some modern displays (~2021) (e.g. MacBook M1, some OLED TVs) support HDR, but it is still a rare feature.

There are multiple formats for HDR images, e.g.:

Ultra HDR uses the JPEG multi-picture format (MPF). It stores the normal SDR JPEG image as the first image, so all existing JPEG decoders can display the normal image. Then it stores a HDR gain map embedded in MPF which can be used to reconstruct the HDR image.

Currently, (end of 2023), Google Chrome stable (end of 2023) supports this format.
(Another alternative in Google Chrome is AVIF.)
(Firefox currently does not support it.)

Currently, (end of 2023), Google Pixel phones can capture Ultra HDR images (e.g. when they use night mode).

(Note, many websites, e.g. Twitter, will reencode JPEGs after you upload them, and often they don't support Ultra HDR yet, so then it will be lost, and you will just see the normal SDR JPEG image.)

About the Ultra HDR format:
https://developer.android.com/media/platform/hdr-image-format

This document defines the behavior of a new file format that encodes a logarithmic range gain map image in a JPEG image file. Legacy readers that don't support the new format read and display the conventional low dynamic range image from the image file. Readers that support the format combine the primary image with the gain map and render a high dynamic range image on compatible displays.

To use the simple script here, for preparation:

This script does nothing fancy: It just upscales the input JPEG color range (FFmpeg does that here currently) and then encodes the HDR gain map using Google's Ultra HDR encoder (libultrahdr). The effect is that the image will display brighter on HDR displays.

Some related issues:
https://github.com/ImageMagick/ImageMagick/issues/6377
https://github.com/libvips/libvips/issues/3799

Top comments (0)