MFK

Full-Stack Engineer · Pakistan

Open to work · Available immediately

Lumenary

176 ways to see an image, and what I measured about them

📅 2026👤 Solo build, design, engineering and analysis🏢 Personal project👁 25 views
React 18ViteCanvas 2DSCSSKaTeXVercel
Figure 1One source image and six treatments from the same engine at default settings: Dithering (33), Watercolour (82), Ukiyo-e (139), Ajrak (161), Voronoi Mosaic (109) and Gold Foil (64). Every render on this page uses the built-in synthetic still life, not a photograph.
⚠️

Problem

I wanted an image studio that never touches a server: load a picture, see it through a treatment, save the result, and nothing is uploaded. Dozens of visual styles written one by one turn into a pile of near duplicates unless something holds them together.

🔧

Solution

One contract for every treatment: metadata, a list of dials and a create() that returns a renderer. A registry collects the modules, so adding a treatment means adding one file. Once it worked, I measured it: what each treatment computes, how long it takes, and whether my craft pipeline beats ordinary filters.

✦

Result

176 treatments in 13 sections, 1,069 dials and about 50,000 words of theory, all running on the visitor's device. The measurements were mixed, and I kept both halves: the craft pipeline wins on palette adherence and loses to every baseline on edges.

Impact

  • ✦176 treatments in 13 sections: 151 stills and 25 live, all on Canvas 2D
  • ✦1,069 adjustable dials and 528 See it presets that set them from a link
  • ✦About 50,000 words of theory, one page for each treatment
  • ✦Shared toolkit is 5.7% of the code: 744 lines against 12,414 in the style files
  • ✦Median still renders in 118 ms at 480 px and 301 ms at 960 px, on software rendering
  • ✦Craft pipeline: 15 of 15 on palette adherence, last on edge retention

01The Brief

I wanted an image studio that never touches a server. You load a picture, you look at it through a treatment, you save the result, and the picture stays on your device the whole time. That rules out uploads, queues, accounts and any GPU pipeline I would have to host or trust. What is left is the Canvas 2D API, getImageData and a lot of arithmetic... which turned out to be enough.

Four constraints

  • Browser only, nothing uploaded. Every pixel is read and written on the visitor's own device. The only thing that leaves the page is a cookieless page view from Vercel Web Analytics.
  • Cheap to add. I wanted a lot of treatments, so writing one had to be small: one file, one contract, no changes anywhere else.
  • Fast enough on ordinary hardware. A treatment runs in the visitor's tab, so a slow one is a bad page, not a slow server.
  • Explainable. Each treatment gets a theory page that typesets the maths and the history behind it, so the studio teaches something as well as producing pictures.

02What I Built

You bring a photograph (upload, paste or drop one) or use the built-in still life, pick a treatment, turn its dials and export. Stills re-render larger, up to 4096 px, and save as PNG. Live treatments move, follow the cursor and record a six second WebM clip.

Treatments
176
Sections
13
A to M
Stills
151
export PNG
Live
25
record WebM
Adjustable dials
1,069
Words of theory
50,000
about, one page each
See it presets
528
dials set by a link
Pages in the sitemap
206

The 13 sections run from design movements, digital and typographic styles through painterly, optical and generative work to world cultures, Sindhi design (Ajrak, the Indus seal, Hala blue pottery, Sindhi script) and South Asian and Islamic design. Every treatment has a theory page, and most of its suggestions carry a "See it" link that turns the dials for you.

Figure 2Twenty four of the 176 treatments, rendered from the same source image with default settings. Each tile shows the running number, the name and the section letter, A to M. All thirteen sections are represented.

03Architecture

Every treatment is one module in src/engine/styles with the same contract: metadata, a list of dials and a create() that returns a renderer with setSource, setParams, draw and dispose. A still treatment goes through a still() wrapper and only writes a render() function. The 151 stills and 25 live treatments share that one shape.

A registry collects the modules with import.meta.glob and joins them with the section list, so adding a treatment means adding a file. The runtime fits the source image to the style's working size, calls the renderer and draws to a Canvas 2D context, once for a still and every frame for a live one. The pages, the theory pages and the URL presets all configure the same dials, so a link can open a treatment with its dials already turned.

Figure 3System overview. Each treatment is one module that follows the same contract. The registry collects the modules and joins them with the section list. The runtime fits the source image to the style's working size, calls the renderer and draws to a Canvas 2D context: once for stills, every frame for live treatments. Theory pages and URL presets configure the same dials.

The shared toolkit

The tidy story would be that a handful of primitives cover everything. The data says otherwise. The shared modules are 744 lines against 12,414 in the 176 style files, so 5.7% of the combined code. A median treatment uses 6 shared helpers (7 with the still() wrapper) and two use none. Across all 66 helpers, 9 are used by 50 or more treatments, 29 by five or fewer and 8 by exactly one. That is a long tail, so I call it a shared toolkit, not a closed set.

Figure 4(a) The fifteen most widely used shared helpers, as the number of treatments that use each, coloured by source module. The still() wrapper, used by all 151 stills, is left out. (b) Distinct shared helpers per treatment, excluding still(): median 6, mean 6.3, maximum 15; two treatments use none.

04The Taxonomy

To see what the 176 treatments actually are, they were classified by what their code computes, not by the name of the art style, using one written set of rules for all of them. There are eight primary operations: procedural synthesis 69, quantisation and palette mapping 36, geometric warp 17, point operation 15, lighting and material shading 12, simulation 11, compositing 10 and neighbourhood operation 6.

The biggest class is procedural synthesis: marks, patterns and tilings generated from rules, with the photo steering only their size, colour and placement. Only 21 treatments are point or neighbourhood operations, the plain filters of a photo editor. In 78 of the 176, the output depends on tone alone.

Figure 5Primary operation of each treatment by section (176 treatments, eight categories). Procedural synthesis is the largest class (69), then quantisation and palette mapping (36). Numbers inside segments give counts of three or more; the number at the bar end is the section total.

05Performance and Honest Limits

Everything runs in the visitor's tab, so every still was timed at 480, 960 and 1920 px with five repetitions, and every live treatment for 60 frames at 480 and 960 px, in headless Chromium.

Median still at 480 px
118 ms
301 ms at 960 px
Stills under 100 ms at 960 px
20 of 151
fastest: editorial, 47 ms
Slowest still at 960 px
1.6 s
delft blue, then differential growth
Median live frame at 480 px
7.8 ms
11.9 ms at 960 px
Live at 60 fps, 480 px
22 of 25
14 of 25 at 960 px
Slowest live frame at 960 px
139 ms
neon glow; 49 ms at 480 px
Figure 6(a) Median render time of each of the 151 still treatments against the pixels actually rendered, on log scales. The 1920 px request renders near one million pixels, because each style caps its own working size. The thick line joins the median across treatments; the dashed line is cost proportional to pixels from the 480 px median. (b) Distribution at the 960 px request, median 301 ms. Software rendering, so read the values as relative.

Every style caps its own working size, between 900 and 1400 px and mostly 1000 or 1100, so the 1920 px request really renders about 1000 px. For that reason I do not quote a scaling slope across the three widths. Using only 480 and 960 px on the 140 stills that are not capped at 960, cost grows sub-linearly with pixel count (a log-log slope of about 0.6), most likely because fixed setup work such as resampling, tables and noise does not scale.

The live treatments are comfortable at small sizes and tight at large ones. Judged by median frame, 22 of 25 hold 60 fps at 480 px and 14 of 25 at 960 px. Judged by the 95th percentile frame, it is 18 of 25 and 13 of 25. Neon glow is the slowest at 139 ms a frame at 960 px.

Figure 7Median time per frame for the 25 live treatments at 480 px and 960 px requests, log scale, sorted by the 960 px value. The dashed line marks 16.7 ms, which is 60 frames per second. By median, 22 of 25 meet it at 480 px and 14 of 25 at 960 px. Some styles cap their working size below the request. Same software rendering setup.

06The Craft Pipeline, and What Failed

Thirty five of the 38 cultural treatments share one toolbox, engine/culture.js. Five of them (batik, madhubani, Persian miniature, truck art and ukiyo-e) use the same route: blur the picture, snap every pixel to a fixed pigment palette after a saturation push, run a majority filter over the index map to clean up specks, draw outlines on the boundaries, then add decoration such as wax crackle, wood grain, hatching or an artist's seal.

I wanted to know whether that route is worth anything, so I compared it with three ordinary baselines (k-means, a bilateral filter and a Kuwahara filter) on three images at 960 px, 15 runs in all. The baselines have fixed settings that I never tuned, and none of them was given the cultural palettes. The comparison is lopsided on purpose: the pipeline is a style, the baselines are filters.

What it won

Palette adherence. The mean distance from each output pixel to the treatment palette is 5.9 Lab units for the pipeline, against 20.1 for k-means, 20.7 for bilateral, 20.6 for Kuwahara and 20.8 for the untouched input. It was closer than k-means in 15 of 15 runs. That win is partly by construction, because only the pipeline knew the palette. Its clean-up core, without the decoration, is also far tidier: 42 small regions against 2,360 for k-means, counted the same way.

MethodDistance to paletteLab units, lower is betterEdge retentionSobel correlation, higher is betterSmall regionsunder 20 px, lower is better
Craft pipeline, full render5.90.106,762
Craft pipeline, clean-up core only0.00.1642
k-means20.10.802,360
Bilateral filter20.70.971,548
Kuwahara filter20.60.751,526
Table 1Craft pipeline against three baselines, mean over 15 runs (5 treatments, 3 images, inner region of each render). Small regions are counted on nearest palette labels, the same way for every method.

What it lost

Edges. The pipeline's Sobel correlation with the input is 0.10, and 0.16 for the core alone, against 0.80 for k-means, 0.75 for Kuwahara and 0.97 for bilateral. In none of the 15 runs does it beat a baseline. Heavy blur, majority filtering, outlines drawn on index boundaries and added texture all move or create gradients. Some of that is the look I wanted, but by this proxy the pipeline is not edge preserving.

Speckle. The clean core is tidy, but the full render is not. It averages 6,762 small regions against 2,360 for k-means, and it beat k-means in only 5 of 15 runs, all of them truck art or Persian miniature. Batik, madhubani and ukiyo-e are worse than k-means, because fill marks, crackle, wood grain and paper fibre all create small regions of their own.

Figure 8Batik, where the pipeline loses on speckle. On this image it leaves 18,778 small regions against 1,399 for k-means, because wax fill marks, dye mottling and crackle each make regions of their own. Left to right: input, Lumenary pipeline, k-means, bilateral, Kuwahara.
Figure 9Persian miniature, where it wins. On this image it leaves 671 small regions against 1,487 for k-means. It won on two of the three test images. Same order of panels.

Time. In the browser the full render took 871 ms on average, 543 ms for the core. The Python baselines took 135 to 517 ms. The runtimes differ, so read that as an order of magnitude only.

07What I Would Do Next

The results above are a first pass. In rough order of how much each step would change my confidence:

  • A user study. The missing question is whether people prefer what the pipeline makes.
  • A second rater for the taxonomy, with the agreement reported.
  • Fix the speckle in batik, madhubani and ukiyo-e, after separating designed texture from stray regions so the metric stops mixing the two.
  • Repeat the benchmark on real GPU hardware with a production build.

08Stack and Links

React 18 and Vite 5 with SCSS and React Router 6, plus three small libraries for the interface: Motion for springs and scroll-linked animation, Lenis for smooth scrolling and KaTeX for the equations. The image engine itself has no dependencies. It is hosted on Vercel, and Vercel Web Analytics (cookieless) is the only measurement.