Skip to content

Instantly share code, notes, and snippets.

@arudmin
Created January 23, 2014 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arudmin/8579699 to your computer and use it in GitHub Desktop.
Save arudmin/8579699 to your computer and use it in GitHub Desktop.
ImageMagick
// Require our module dependencies
var exec = require('child_process').exec;
// Create command array to invoke ImageMagick composite where
// -dissolve is the amount of transparency for the watermark
// -gravity tells how to align images of varying size
// -quality is the image quality of the JPEG (not required if producing PNG)
var command = [
'composite',
'-dissolve', '50%',
'-gravity', 'southwest',
'-geometry', '+50+100',
'-quality', 100,
'-colorspace', 'gray',
'watermark.png',
'image.jpg',
'out/result.jpg'
];
// Join command array by a space character and then execute command
exec(command.join(' '), function(err, stdout, stderr) {
// Do stuff with result here
if (err) console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment