Menu

Building a Browser-Based Image Editor With Web Workers and OffscreenCanvas

HackerNoon·sammii·about 21 hours ago
#cHSaDiRI
#hackernoon#technology#worker#pipeline#thread
Long article (1711 words) — no AI summary yet.
Reading 0:00
15s threshold

Photoshop can do everything ScapeStudio does. That is not the point. Preparing photographs for fine art prints and T-shirt production is a specific pipeline: greyscale, curves, threshold knockout with feathered edges, export at 300 DPI across fixed paper and garment sizes. In Photoshop, that is opening each file, running an action, exporting, renaming, repeating. Twenty photographs is an afternoon.

ScapeStudio does those four steps, nothing else, and the entire pixel pipeline runs in a Web Worker. Dragging a curves handle has to re-render the preview in under 16ms or the feel is gone. Main-thread processing on a 24-megapixel shot cannot hit that. A worker with an OffscreenCanvas can.

Why the main thread loses

Canvas 2D is not slow in itself. Every pixel operation on the main thread competes with layout, paint, input handling, and React reconciliation. Luminance conversion on an 8000x6000 image is 48 million pixels, 192 million byte operations. On a warm JIT, around 150ms.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.