looking for an imagemagick nodejs npm?

13,758

Solution 1

I chose to use gm node module on one of my project. It works pretty well.

See : http://aheckmann.github.com/gm/

It's basically a wrapper around imageMagick or graphicsmagick binaries.

Here is a simple example :

var gm = require('gm');
gm('/path/to/image.jpg')
.resize(353, 257)
.autoOrient()
.write(writeStream, function (err) {
  if (!err) console.log(' hooray! ');
});

Solution 2

I once was in your position and after getting really frustrated with modules that had bugs or weird APIs I started using imagemagic directly by spawning a child process. Node.js is pretty good at this so it's actually not that hard.

var spawn = require('child_process').spawn;
var args = ['-ping', 'tree.gif' ];
var composite = spawn('identify', args);

It's also great because you can just use the imagemagic documentation.

Share:
13,758
mkoryak
Author by

mkoryak

Senior software engineer at Google in Cambridge. Author of jquery.floatThead - fixed table headers (1K stars on github) https://github.com/mkoryak

Updated on June 08, 2022

Comments

  • mkoryak
    mkoryak about 2 years

    I have bene using node-imagemagick for a few days now and have come to realize that it has bugs.

    There are about 100 forks of it, some of which fix some of the issues i have come across, but it is hard to figure out which fork i should use.

  • CodeMind
    CodeMind over 6 years
    This is not working at all for me.getting { [Error: Command failed: Invalid Parameter - -resize ] code: 4, signal: null } .:/
  • jcreignou
    jcreignou over 2 years
    new link is : npmjs.com/package/gm