Nodes/Comfy-FilmSimulator/DNG Image Reader (Rawpy)
ComfyUI Node

DNG Image Reader (Rawpy)

Your camera's raw files, inside ComfyUI, with no Lightroom detour

By zhuyanan·Created 9 months ago·Updated 3 months ago· 1
DNG Image Reader (Rawpy)
    • image
    • metadata
    dng_path
    linear_outputtrue
    wb_modeAs Shot
    target_max_exposure0.50

    The Comfy-FilmSimulator pipeline starts with a camera raw file, and this is the node that gets it in. It's a rawpy (libraw) front end that demosaics a DNG - or just about any raw your camera shoots, since rawpy speaks whatever libraw speaks - and hands ComfyUI a float32 image plus a metadata string. If you've ever wanted to run a film grade on a photo before it's been baked into a JPEG by your camera's engine, this is the door. It's also the only node in the pack with real photographic machinery under the hood: white balance multipliers, 16-bit demosaicing, and a physical exposure scale instead of the usual "brightness slider that lies to you."

    How it works. The node calls rawpy.imread() on your path, then raw.postprocess() with your chosen white balance mode. The interesting part is what it does after: it normalizes the demosaiced image by the sensor's white level and multiplies by target_max_exposure, so the output is a linear, scene-referred float image in roughly 0–1 territory. That's exactly what the film simulation node wants, and it's why this reader exists rather than loading a JPEG. When linear_output is off it demosaics with a 2.2 gamma instead, which gives you a more preview-friendly but non-linear image.

    The inputs that matter. Four, and honestly only two of them are decisions:

    • dng_path - absolute or relative path to the raw file. That's it, that's the whole job of the node.
    • target_max_exposure (default 0.5) - per the author's own tooltip, this is physical gain: 0.5 matches most camera previews, 1.0 is the sensor clipping point. Treat it as exposure. Crank it past 1.0 and you're deliberately pushing highlights.
    • wb_mode (default "As Shot") - lets you override the camera's white balance with a grey-world auto, a Kelvin preset, or "None (Raw Sensor)" for the untouched Bayer values. Since FilmSimNode has its own Kelvin/tint WB control, this is mostly for getting the source in a sane state.
    • linear_output (default true) - keep it on unless you specifically want a gamma-encoded image.

    What comes out. Two outputs. image is the float tensor that wires straight into FilmSimNode's image input. metadata is a string with camera make/model, bayer pattern, WB multipliers, and black/white levels - wire it into a text-display node if you want to see what your sensor actually said. This output doubles as the error channel: on a bad path or an unreadable file the node returns a blank black 512×512 image and puts the error message in metadata. So when everything looks wrong, read the string, not the picture.

    Install. Via Manager (search "Comfy-FilmSimulator") or cd ComfyUI/custom_nodes && git clone https://github.com/zhuyanan/Comfy-FilmSimulator, then restart. No model files. The dependency to watch is rawpy - it's a compiled native package, and if ComfyUI throws an import error for it at startup, pip install rawpy fixes it. It has wheels for common platforms, so you usually don't need a compiler.

    Where people get burned. A typo'd path silently producing a black image with the error hidden in metadata is the classic one. Second place: forgetting this outputs linear values and plugging it into a normal preview chain without the film node's SDR path - everything looks dark because it's scene-referred, not gamma-encoded. Keep it on the film pipeline's input, and you're fine.

    CategorySmartHDR

    Inputs (4)

    NameTypeDefaultDescription
    dng_pathSTRING
    linear_outputBOOLEANtrue
    wb_modeCOMBOAs Shot7 options: As Shot, Auto (Grey World), Daylight (5500K), Tungsten (2850K), Fluorescent (3800K), Flash, +1
    target_max_exposureFLOAT0.500.1–10Physical Gain. 0.5 matches most camera previews. 1.0 is sensor clipping point.

    Outputs (2)

    NameTypeDescription
    imageIMAGE
    metadataSTRING