Technical document

How it works

A gain map image carries two things: a standard SDR baseline every app can open, and a secondary brightness layer (the gain map) that HDR displays use to expand highlights past SDR reference white. Gainmaps synthesizes that second layer locally, in your browser, from the pixels you give it.

What changes

The worker rasterizes your photo, builds linear HDR capacity from the SDR pixels using the chosen gain intensity, tone-maps an SDR base, and writes a single gain map image. The output file is larger than the input: it carries both the SDR image and the gain map, but opens normally in any JPEG viewer.

This is not camera-scene HDR reconstruction. Without original HDR capture data, the tool synthesizes headroom from the SDR image. Compatible viewers (Apple Preview, Photos, Android Ultra HDR clients) can then expand the gain map on capable displays.

Pipeline

  1. 1Files arrive via drag-and-drop or the file picker.
  2. 2The page sends each file to /hdr-service-worker.js over a MessageChannel.
  3. 3The worker detects format: PNG, JPEG, GIF, HEIC, WebP, AVIF, or any browser-decodable bitmap.
  4. 4Pixels are decoded to RGBA and converted to linear light.
  5. 5Linear values are scaled by gain intensity, creating synthetic HDR capacity.
  6. 6A gain map is computed against a Reinhard-tone-mapped SDR base image.
  7. 7The result is encoded as an Ultra HDR JPEG Blob and returned for download.

Formats

Input: PNG, JPEG, WebP, AVIF, GIF (first frame only), HEIC when the browser decoder can open it, and SVG including animated SMIL/CSS SVG. Animations are frozen to a keyframe, then encoded.

Output: a JPEG-container gain map — JPEG inputs keep their extension; other containers write as *-gainmap.jpg. The file contains both layers and can be opened by any standard JPEG viewer.

Privacy

Files never leave the browser for processing. The service worker encodes locally and returns a downloadable blob. No bytes travel to any server. Closing the tab discards all in-memory results.

The converter works offline after the first load. There is no backend, no analytics pipeline, no upload endpoint.

Limits

Very large images may be slow to encode in-browser; the worker is single-threaded per file. Animated GIF only encodes the first frame. HEIC decoding depends on platform support. Gain-map appearance varies by viewer software and display peak luminance: the same file looks different on an iPhone XDR versus an SDR monitor.

How it works · Gainmaps