imagemagick-stream

Streaming Imagemagick api

imagemagick-stream

Streaming imagemagick api

$ npm install imagemagick-stream
var im = require('imagemagick-stream');
var read = fs.createReadStream('image.png');
var write = fs.createWriteStream('image-resized.png');
 
var resize = im().resize('200x200').quality(90);
read.pipe(resize).pipe(write);
 
// Alternatively 
im('image.png')
  .resize('200x200')
  .quality(90)
  .pipe(write);
 
// Or 
im('image.png')
  .resize('200x200')
  .quality(90)
  .to('image-resized.png');

For freehand settings and operations, use .op() and .set(). See the imagemagick docs for a list of available options.

im('image.png')
  .set('density', 400)
  .set('channel', 'RGB')
  .resize('200x200')
  .op('gaussian-blur', 0.05)
  .to('image-resized.png');

NOTE: You shold listen to the finish event on the writable stream you're piping to, not the stream from ImageMagick:

var read = fs.createReadStream('image.png');
var write = fs.createWriteStream('image-resized.png');
var resize = im().resize('200x200').quality(90);
 
write.on('finish', function () {
  // finished writing 
});

MIT