A collection of Javscript image manipulation utilties and effects filters.
Given a createCanvas
function.
const createCanvas = (img) => {
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
const context = canvas.getContext('2d');
context.putImageData(img, 0, 0);
return canvas;
};
Simple example of hatch-filter
const img = await loadImage('example.jpg', { width: 200, height: 200 });
// Cross-hatch effect
const hatch = hatchFilter(img, 1.0, 0.7, 0.5, 0.25);
const hatchCanvas = createCanvas(hatch);
document.body.append(hatchCanvas);
With CDN, showing composition of filters to create a dodge-burn effect
<script type="module">
import * as ImageUtil from "https://cdn.jsdelivr.net/gh/mwdchang/image-util@latest/dist/index.js"
const img = await ImageloadImage('example.jpg', { width: 200, height: 200 });
// Dodge burn effect
const burn = ImageUtil.dodge(
ImageUtil.invertFilter(ImageUtil.uniformBlur(ImageUtil.greyScaleFilter(img), 8)),
ImageUtil.greyScaleFilter(img)
);
const burnCanvas = createCanvas(burn);
document.body.append(burnCanvas);
</script>
npm run build
Runs on http://localhost:8090
npm run develop
- sepia, polaroid, technicolour, kodakChrome, vintage, browni, gaussian-blur, uniform-blur, glow, sharpen, emboss, laplacian, sobel
- dodge, grid, hatch, fishEye, painterly, SLIC, shear, sketching