Creates a gain map
The map's pixels: grey (red, green and blue the same) for one map for all channels. Its alpha is ignored
See GainMapOptions
log2 of the boost of the map's value 255, per channel
log2 of the boost of the map's value 0, per channel (red, green, blue)
the gamma the map's values are stored with, per channel
log2 of the display headroom at which it applies fully
log2 of the display headroom from which on the map starts to apply
subtracted from the HDR result, per channel
added to the SDR image's linear values before the boost, per channel
whether the boost applies in the SDR image's color space (else in the HDR image's)
1 for a grey map (one boost for red, green and blue), 3 for one per channel
The map's height
The map's width
Clones the gain map (its pixels too)
StaticdecodeDecodes a gain map JPEG with its parameters (hdrgm XMP or ISO 21496-1), like the second image in an Ultra HDR JPEG, or the gain map of an Ultra HDR JPEG (or an iPhone's JPEG: its values converted to these parameters)
The JPEG
Encodes the gain map alone: a JPEG with its parameters (hdrgm XMP and ISO 21496-1), like the second image in an Ultra HDR JPEG
Optionalquality: numberThe JPEG quality (1-100). Default: 90
A gain map: a small image saying how much brighter each part of an image gets on an HDR display, as Ultra HDR (JPEG-R) photos from phones carry it. HDR displays show the image boosted by it, the others the image as it is.
Image.decode reads the gain maps of JPEGs, AVIFs and JPEG XLs into Image.gainMap, Image.encodeJPEG, Image.encodeAVIF and Image.encodeJXL write them. The map covers the whole image, at any resolution (phones write a quarter of the width and height). Its value
v(0-255, per channel or one for all) boosts the linear light of the image by2^(gainMapMin + (gainMapMax - gainMapMin) * (v / 255)^(1 / gamma))