A Javascript library to bring common image processing effects to the browser, realtime.
* this is archived content ported from an older design with minimal intervention
In late 2010 I spent time looking at the then-new HTML5 canvas element and realized that the ability to run various functions on any pixel within a defined area meant that common image manipulation abilities from photo manipulation apps were a real possibility.
Over a couple of months I went deep on image processing algorithms and performance optimization, learning how to implement things like convolution matrices and bit shifting to create a lightweight, browser-based image manipulation library. This was also the first true open source project I launched and it garnered some useful contributions back upstream.
Aside from the main image processing functions, another issue I needed to solve was the interface to pull a document’s images into the canvas element and get them back out into the document somehow without requiring extra configuration on the author’s part. The technique I landed on had the script check for a set list of filter classes to define where to apply a filter. For each match, the script pulls in the image data regardless of whether it found an img element or CSS background image, and renders it to an off-screen canvas element, applying the filter and capturing canvas contents to a data-uri that replaces the original source with processed image data.
The W3C filter effects spec has made PaintbrushJS thoroughly redundant today, but in 2010 this was the only way to accomplish these effects on the fly without the assistance of a heavy server-side library.