Goal: There should be less friction when sharing great HDR app experiences on the web. This macOS Hammerspoon script takes a clipboard full of HDR HEIC data from Screenshot.app (or ⇧⌘⌃4) and, on a quick double-paste, converts it into whatever a GitHub issue or similar website actually accepts:
uhdr),png-hdr),avif, not for GitHub yet),png-sdr), to avoid switching Screenshot.app’s capture format manually.Cycle modes with ⌃⌥⌘-H.
Situation: In macOS 26 Tahoe, when enabled as shown below, Screenshot.app and screencapture can capture HDR screenshots, including via the normal clipboard keyboard shortcuts (e.g. ⌃⇧⌘-4).
HDR formats are complex, evolving, and not always lossless. Apple’s semi-proprietary lossless HDR HEIC encoding doesn’t render in most web browsers or survive through website uploads. PNG has no standard HDR mechanism. PNG can carry 16-bit HDR data as a container, but only Safari and Preview know what to do with it. Other viewers read the 16-bit PNG’s pixel values as ordinary sRGB, so the image looks blown out rather than merely flat.
Problem: After switching Screenshot.app to HDR Capture Mode, pasting the HEIC into a GitHub text box in Safari does nothing. GitHub silently drops it. Chrome-based browsers instead convert the HEIC to PNG client-side before upload, which strips the HDR data and uploads a washed-out image.
Solution: Paste twice quickly in Safari. Hammerspoon runs a Swift snippet heic-hdr-decode to read the HEIC out as a macOS-only PNG or a TIFF. This part has to stay Apple-only. It reads proprietary tone-curve metadata that no cross-platform library understands. From there, libvips can optionally convert that TIFF into an Ultra HDR (uhdr) JPEG, which gets written back to the clipboard in place of the original HEIC.
As I understand it, --interpretation scrgb isn’t a complete match to P3. So there’s noticeable loss in gamut versus the original HEIC. It’s directionally correct, though.
Dependencies: brew install libvips for uhdr jpg, brew install libavif for avif, XCode CLI tools (for swiftc), Hammerspoon.
sleep 10; screencapture -H -theic -x ~/Desktop/screenshot-screenshot4.heic
# uhdr
~/.hammerspoon/bin/heic-hdr-decode ~/Desktop/screenshot-screenshot4.heic /tmp/test5.tiff uhdr
vips copy /tmp/test5.tiff /tmp/test4-uhdr.jpg --interpretation scrgb
# avif
~/.hammerspoon/bin/heic-hdr-decode "~/Desktop/screenshot-screenshot4.heic" /tmp/test-hdr.png png-hdr
avifenc --ignore-icc --cicp 12/16/1 -d 10 /tmp/test-hdr.png /tmp/test-avifenc.avif
Limitations & Notes:
Either of the original HEIC files can be viewed by pressing the “Raw” button on the Gist below, especially in Safari.
| HDR capture and clipboard conversion to lossy JPEG UHDR | PNG SDR capture |
|---|---|