Factory code extract from AlloyPhoto, a html5 photo processing library.