node-pixelate
v0.0.3
Published
Pixelate images
Downloads
3
Readme
pixelate
Pixelate images
Install
npm install node-pixelate
It's using node-canvas (rather than ImageMagick) and one of the requirements for it is the Cairo canvas implementation, so Cairo needs to be installed. Instructions.
Usage
var fs = require('fs');
var pixelate = require('node-pixelate');
fs.readFile(__dirname + '/images/street.png', function(error, dataBuffer) {
if (error) throw error;
pixelate(dataBuffer, {
// scale down 90 percent (really pixelated). Default: 0.
scale: 0.9,
// max width keeping aspect ratio, unless height specified. Default: original width.
width: 500,
}, function(error, pixelatedDataBuffer) {
fs.writeFile(__dirname + '/images/pixelated-street.png', pixelatedDataBuffer, function(error) {
if (error) throw error;
console.log('Done.');
});
});
});
Requirements
Mac OS X
brew install graphicsmagick
License
MIT