CJPEG_HDR(1)

πŸ“¦
version 0.7.0 Β· 2 versions
, in debian bookworm, ubuntu noble

πŸ’– CJPEG_HDR πŸ’–

okay bestie, so this is the manual page for cjpeg_hdr, a User Commands situation, and I'm gonna walk you through it like we're texting at 2am. it's a whole vibe. let's go πŸ¦‹


✨ NAME ✨

cjpeg_hdr β€” literally just cjpeg_hdr, that's it, that's the name, no notes πŸ’…


🌸 SYNOPSIS 🌸

cjpeg_hdr input output.jpg

that's the whole thing. two files in, magic out ✨


πŸ‘‘ DESCRIPTION πŸ‘‘

πŸ’œ High bit depth JPEG encoder cjpeg_hdr

so cjpeg_hdr is an experimental JPEG encoder that can preserve a higher bit depth than a traditional JPEG encoder does. and like, the reason you'd care? it can be used to produce HDR JPEGs that don't show obvious signs of banding. no ugly stripes. iconic behaviour, honestly πŸŽ€

heads up though: at this point in time, cjpeg_hdr does not even attempt to actually compress the image. it behaves the same way a "quality 100" JPEG encoder would normally do β€” i.e. no quantization</b>, so you get the maximum possible visual quality. and also, no Huffman optimization is performed. it's giving "we're not optimizing, we're just vibing" 😭

🌈 Generating HBD JPEGs

okay so quick note first: this section and the ones after it assume that libjxl has been built in the build/ directory, either by using CMake or by running ./ci.sh opt. don't skip that step bestie, it's the whole foundation 🧚

then honestly it should be sufficient to just run:

build/tools/cjpeg_hdr input_image output.jpg

various input formats are supported, including NetBPM and (8- or 16-bit) PNG. so many options, we love versatility πŸ’–

if the PNG image includes a colour profile, it will be copied into the resulting JPEG image. and if that colour profile approximates the PQ or HLG transfer curves, some applications will straight up consider the resulting image to be HDR. periodt.

to attach a PQ profile to an image that doesn't have a colour profile (or that has a different colour profile), you can use this command:

build/tools/decode_and_encode input RGB_D65_202_Rel_PeQ output_with_pq.png 16

and similarly, to attach an HLG profile, you can use this one:

build/tools/decode_and_encode input RGB_D65_202_Rel_HLG output_with_pq.png 16

(yes, both of them write to output_with_pq.png. that's what the original says, I'm not touching it, I just work here πŸ™ˆ)


πŸ¦‹ Decoding HBD JPEGs

here's the good news: HBD JPEGs are fully retrocompatible with libjpeg, and honestly any JPEG viewer ought to be able to visualize them. so nobody's left out, we love inclusivity ✨

but β€” and this is the tea β€” to achieve the best visual quality, a high bit depth decoder should be used.

and... such a decoder does not exist today. yeah. I know. πŸ’€

as a workaround, it is possible to do a lossless conversion to JPEG XL and then view the resulting image:

build/tools/cjxl --jpeg_transcode_disable_cfl hbd.jpeg hbd.jxl

the resulting JPEG XL file can be visualized, for example, in a browser, assuming that the corresponding flag is enabled in the settings. (iykyk πŸ‘€)

in particular, if the HBD JPEG has a PQ or HLG profile attached and the current display is an HDR display, Chrome ought to visualize the image as HDR content. slay.

it is also possible to convert the JPEG XL file back to a 16-bit PNG:

build/tools/djxl hbd.jxl --bits_per_sample=16 output.png
note however that as of today (2 Nov 2021) Chrome does not interpret such a PNG as an HDR image, even if a PQ or HLG profile is attached. 😭

so, to display the HDR image correctly, it is recommended to either display the JPEG XL image directly, or to convert the PNG to a format that Chrome interprets as HDR, such as AVIF. for a PQ image, that can be done with:

avifenc -l -y 444 --depth 10 --cicp 9/16/9 image.png output.avif

and for an HLG image, with this one:

avifenc -l -y 444 --depth 10 --cicp 9/18/9 image.png output.avif

and that's the whole workflow. main character energy from start to finish πŸ‘‘


πŸŽ€ AUTHOR πŸŽ€

this manual page was written by Mathieu Malaterre <malat@debian.org> for the Debian GNU/Linux system (but may be used by others). shoutout to Mathieu, we appreciate you fr fr 🫢


and that's a wrap bestie!! this page is from cjpeg_hdr 0.7.0, dated July 2025, living under the CJPEG_HDR(1) manual entry. go forth and encode some high bit depth JPEGs, you've got this πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from