Recommended embedding method
This is the currently recommended embedding method, which uses JPEG-XT, AVIF and MP4 files generated by HDRJPG to attain a near-100% browser compatibility as per the current status of current standards and browser technology.
Embed the image in your HTML like this:
<div class="hdrjpg" data-mp4-src="image.mp4">
<picture>
<source srcset="image.avif" media="all and (min--moz-device-pixel-ratio:0) and (min-resolution: 3e1dpcm) {}" type="image/avif" />
<img src="image.jpg" loading="lazy" decoding="async" style="image-rendering: -webkit-optimize-contrast;">
</picture>
</div>
Then add the hdrjpg-js script to the page. It plays the HDR video in place of the picture in the browsers that cannot show the image in HDR, such as Firefox and Safari on a Mac, and leaves the page alone everywhere else:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/hdrjpg.min.js" defer></script>
If you're using npm, install the package instead:
npm install hdrjpg-js
And import it in your app:
import 'hdrjpg-js';
Users with obsolete browser versions or without an HDR compatible screen will see a standard dynamic range instead.