The discussion addresses the lack of HDR image support in Discourse, which davidkingham noted was previously functional but now fails due to increased image processing. awesomerobot explains that current optimization strips HDR metadata and recommends using AVIF format with a gain map to bypass optimization. However, because gain maps are removed during resizing, HDR only displays when viewing the full-sized image in the lightbox, not in thumbnails, unless the Create thumbnails setting is disabled.
davidkingham confirmed AVIF works after troubleshooting, identifying that their CDN’s WebP optimization was interfering; they resolved it by creating an edge rule to exclude AVIF files. The user then asked if JPEG gain map support (via ImageMagick/libultrahdr) could enable HDR thumbnails in the future. Falco expressed a preference for preserving image formats and metadata like HDR during the resizing process.
I’m curious if there are any plans to support HDR images in Discourse? In my recent testing on my site I could not get images to display HDR. This is odd because I tested this many years ago and it did work, but maybe that support has been removed?
Yeah, it’s not that we specifically removed support… it’s that we do a lot more image processing and optimization than we used to and it’s a consequence of that.
I did some testing on a local instance, and I think the key for HDR images in Discourse right now is to use an AVIF format with a gain map, which will avoid optimization without any site setting changes.
One catch is that we do not keep the gain map when resizing, so if your site has the Create thumbnails site setting enabled… then you only see the HDR version of the image when you click the thumbnail to view the lightboxed image. You could disable that setting, but it means everyone visiting your site is always downloading the full sized image… which can be quite a lot on slow or metered connections, but maybe this is an acceptable tradeoff on a photography site.
Here’s an example AVIF image from Eric Chan that should work in HDR on Meta when opened in the lightbox. You can probably see some color shifts going from thumbnail → lightbox.
Thank you for the helpful response Kris! I stupidly hadn’t thought to try AVIF. That makes sense with the thumbnails, seems to be the achiles heel of HDR everywhere. I’m posting an AVIF below to test because it’s not working on my instance…
Inline in the post it’s stripped, but it should be fine when clicked and opened in the lightbox I just downloaded the original from the post and I can see there’s a gain map in the metadata
I found the culprit! It was the CDN. Bunny had WebP optimization turned on. I created an edge rule to exclude AVIF, and it’s working now. Thanks, Kris!
Are there any plans to extend HDR support beyond the lightbox? I’m not a developer, so I may have this wrong. From what I can tell, ImageMagick added support for JPEG gain maps through Google’s libultrahdr (PR #7198). It looks like it needs to be built with libultrahdr and uses a uhdr: coder. Could that make HDR thumbnails possible in Discourse someday? I’d love to see it for photography communities like ours.