项目作者: miguelmota

项目描述 :
Pixelate images using buffers
高级语言: JavaScript
项目地址: git://github.com/miguelmota/node-pixelate.git
创建时间: 2015-02-13T09:05:01Z
项目社区:https://github.com/miguelmota/node-pixelate

开源协议:

下载


pixelate

Pixelate images

Install

  1. 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

  1. var fs = require('fs');
  2. var pixelate = require('node-pixelate');
  3. fs.readFile(__dirname + '/images/street.png', function(error, dataBuffer) {
  4. if (error) throw error;
  5. pixelate(dataBuffer, {
  6. // scale down 90 percent (really pixelated). Default: 0.
  7. scale: 0.9,
  8. // max width keeping aspect ratio, unless height specified. Default: original width.
  9. width: 500,
  10. }, function(error, pixelatedDataBuffer) {
  11. fs.writeFile(__dirname + '/images/pixelated-street.png', pixelatedDataBuffer, function(error) {
  12. if (error) throw error;
  13. console.log('Done.');
  14. });
  15. });
  16. });

Requirements

Mac OS X

  1. brew install graphicsmagick

License

MIT