← all posts site ↗

film lab in the browser

started with a simple ask: process low-quality esp32 camera images through a film-style filter in the browser. ended up building three iterations of a full pixel processing pipeline that emulates real film stocks instead of just slapping a lut on things. the first version was a single-file digicam tool with sliders for pixelation, bit crush, chroma blur, and vignette. it worked but it was painfully slow because it ran multimillion-operation javascript pixel loops on the full image every time you touched a slider, with no debounce and no size cap.

the second version introduced the concept of film stock emulation versus filter presets. each stock has a characteristic curve, a color matrix, split toning values, and halation settings. the characteristic curve is the big one — real film has a toe where darks lift, a linear mid, and a shoulder where highlights compress and roll off instead of hard clipping. that shoulder is where the creamy highlights come from. halation is the orange glow around bright light sources caused by light bouncing off the film base and re-exposing the red-sensitive layer from behind. split toning adds cool tints to shadows and warm tints to highlights based on pixel brightness, which is the single biggest difference between a filter and actual film look.

the third iteration was all about performance. preview renders at max four hundred eighty pixels wide, debounced by one hundred twenty milliseconds. the display canvas is just css-scaled up with image rendering pixelated. added cross-processing shifts, light leaks, softness glow, and a digicam crust mode that does quantized bit reduction with ordered bayer dither. the pipeline order matters for realism — it goes color matrix, tone curve, split toning, cross-processing, saturation, halation, grain, light leak, vignette, chroma bleed, softness, then dither. each step models an actual physical defect in the film or camera chain rather than just an aesthetic overlay. the whole thing is a single html file you open in a browser and drag images into.