Back to browse
GitHub Repository

rawtohdri Converts bracketed camera raw files directly to an OpenEXR format HDRI.

3 starsCommon Lisp

I created a RAW to HDRI stacker in (mostly) Common Lisp

by aaronestrada·Jun 5, 2026·3 points·0 comments

AI Analysis

●●SolidWizardryNiche Gem

SIMD-optimized Common Lisp with zero-copy EXR writing beats the 15-year-old Python version.

Strengths
  • sb-simd library usage shows genuine performance optimization in an unusual language choice
  • Custom pure Lisp EXR implementation with minimal memory footprint and no bloat
  • Thread-parallel RAW conversion with in-memory floating point stacking
Weaknesses
  • Linux-only with no Windows or macOS builds limits the potential user base
  • Very niche audience — HDR photographers who also care about Lisp are rare
Category
Target Audience

Photographers and HDR enthusiasts working with bracketed exposures

Similar To

Luminance HDR · Photomatix · OpenImageIO

Post Description

This is an upgrade of a tool I created 15 years ago in Python to learn OOP and solve some inadequacies in the HDR stacking tools I could find at the time. The problem was, none of them were really "batch friendly". None of them properly preserved the metadata I wanted them to stuff into the output file. There were probably some other reasons also, I just can't remember them now.

It got the job done, but was very slow. Python was what I knew at the time and even with NumPy, I was limited in the speed I could squeeze out of it. (I also made some very specific, conscious, architectural choices to be extra frugal with RAM, which impacted performance further.)

This new version is SUBSTANTIALLY faster than the old one. This time around the exercise was more about having some fun in Lisp and exploring SIMD in SBCL via the built-in sb-simd library.

It uses LibRaw (via its C API wrapper and CFFI) for reading and and a custom multi-threaded pure Lisp implementation of (a subset) of OpenEXR I created for writing the output files. The threading helps speed up the otherwise expensive deflate based codec and goes a long way towards speeding up the end-to-end pipeline. The core processing / compositing logic is pure Lisp.

Cool features:

* Buffer parallel (threaded) LibRaw reads

* Frugal use of memory (RAW read as 16 bit INT and is only upcast to float during actual stacking)

* AVX2 acceleration of 16 bit INT up-cast and HDR stacking loop

* Threaded OpenEXR writes

* EXIF to EXR metadata preservation of the "center" exposure bracket, which essentially forwards meaningful telemetry regarding the radiometric "reality" of the scene when it was photographed downstream to subsequent consumers.

You can learn more about it and the "algorithm" it uses from the repo. The math for HDR stacking is really very simply if you know basic compositing and understand how digital camera sensors work.

Similar Projects