I am seeing surprisingly slow performance from GraphicsMagick for Node.js using the GM npm module.
I have a simple 16px X 16px icon called icon16.png (320 Bytes). I am simply taking a buffer of this PNG and outputting it to a new buffer using GM (in other words, I am just invoking GM and passing the image through with no manipulation in order to find the performance issue).
var timeStart = parseInt(Date.now());
var newBuffer = gm(icon16buffer, 'icon16.png')
//.resize(8, 8)
.toBuffer(function (err, buffer) {
if (err) {
next();
}
else {
console.log(parseInt(Date.now()) - timeStart);
send(200, buffer);
}
});
};
This takes 175ms (ie. the console.log output is 175). Why so long? Does the C++ GraphicsMagick library have to be loaded from disk each time? Note: I am using SmartOS on Joyent.
The gm
module calls out to a command-line tool. You might look at using graphicsmagick2 instead, which is an actual binding to the graphicsmagick library. Unfortunately there is no documentation, so you'll have to read the source for that (which isn't too long).