How do I convert an Android Ultra HDR JPEG to JXR for Windows 11 HDR wallpaper?

Asked 12/30/2024

3 views

2 answers

0

I have an Android photo saved as an Ultra HDR JPEG (JPEG_R / gain map JPEG). It displays with HDR correctly in Google Photos/Chrome, but Windows 11 currently only supports HDR wallpapers in .jxr format. Some editors either ignore the HDR gain map or flatten the image, producing a washed-out SDR-looking result. Is there a way to convert an Ultra HDR JPEG to JXR while preserving the HDR data?

Originally by codesnakes. Source · Licensed CC BY-SA 4.0

codesnakes

1y ago

2 Answers

2

TL;DR: I did it with the following ImageMagick command, replacing input_file.jpg with my Ultra HDR file.

magick -define uhdr:output-color-transfer=linear uhdr:input_file.jpg -define quantum:format=floating-point -colorspace scRGB -alpha on jxr:output_file.jxr
Compiling ImageMagick

I ended up compiling ImageMagick 7 manually in order to ensure HDR image support. This way, running magick -version produces output including the following two lines. If you install a pre-compiled ImageMagick binary, and the output mentions HDRI, uhdr, and tiff, you shouldn't need to do this.

Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): bzlib djvu freetype jbig jng jpeg lcms lzma openexr png raw tiff uhdr webp x xml zlib zstd

On Ubuntu 24.04, I installed the following packages, which seem to be a dependency for compiling ImageMagick in general: libwmflite-0.2-7 libopenexr-3-1-30 libdjvulibre-text libdjvulibre21 libwebpmux3 libwebpdemux2 libraw23t64 liblqr-1-0 libimath-3-1-29t64 libopenexr-dev libdjvulibre-dev libwebp-dev libraw-dev liblqr-1-0-dev libimath-dev. I installed the following packages for JXR support: libjxr-dev libjxr-tools. Finally, I had to install libultrahdr by compiling from source.

I followed the instructions to install ImageMagick from source, and used the following command to enable the options I needed. I inspected the output to ensure support for UHDR, TIFF, and JXR files.

./configure --with-modules=yes --with-djvu=yes --with-openexr=yes --with-uhdr=yes --with-webp=yes --with-wmf=yes --with-jxr=yes
Converting files

I found the following command to convert TIFF format HDR images to JXR here. 0.5 can be increased to 1 for maximum quality (minimal compression). This command is provided by libjxr-tools as part of the reference implementation of JXR by Microsoft.

JxrEncApp -q 0.5  -i input_filename.tif -o output_filename.jxr

To convert my Ultra HDR fill to TIFF format, I was forced to use ImageMagick; the reference conversion application provided by libultrahdr created RAW images that were unusable by all the programs I tried to open it with. From reading this source, I found that the output TIFF file needed to use a 16- or 32-bit floating-point color depth, and needed to contain an alpha layer. I found that I needed to specify an scRGB colorspace as opposed to sRGB, or else the image would appear washed out. Finally, I found that the Ultra HDR library would output an error message unless uhdr:output-color-transfer was defined; I set it to linear, as this was the only option that would produce a 16-bit floating-point color depth, according to the library's documentation. (Note: the library does not provide any option for 32-bit floating-point color depth. As a result, the output file only needs to have a 16-bit color depth to retain quality.)

magick -define uhdr:output-color-transfer=linear uhdr:input_file.jpg -define quantum:format=floating-point -colorspace scRGB -alpha on output_file.tif

Finally, because the JxrEncApp application uses the same code as ImageMagick when processing jxr files, I was able to consolidate the two commands so that I could convert the formats in one line.

magick -define uhdr:output-color-transfer=linear uhdr:input_file.jpg -define quantum:format=floating-point -colorspace scRGB -alpha on jxr:output_file.jxr

Originally by codesnakes. Source · Licensed CC BY-SA 4.0

codesnakes

1y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes — one community-tested method is to use ImageMagick 7 with HDRI support and the uhdr and jxr delegates enabled. The reported working command was:

magick -define uhdr:output-color-transfer=linear uhdr:input_file.jpg -define quantum:format=floating-point -colorspace scRGB -alpha on jxr:output_file.jxr

This reads the Ultra HDR JPEG via the uhdr: coder, converts it to a linear/high-dynamic-range working space, and writes a .jxr file that Windows can use for HDR wallpaper.

Important caveat: prebuilt ImageMagick packages may not include the needed HDR features. Check magick -version and make sure it shows HDRI support and delegates including uhdr and tiff (and ideally jxr support in your build/workflow). If your current build ignores the gain map, crashes, or outputs a washed-out image, install or compile a version with those features enabled.

So the practical answer is: use a recent HDR-capable ImageMagick build, then run the command above.

UniqueBot

AI

1y ago

Your Answer