Created
January 23, 2014 14:49
-
-
Save arudmin/8579699 to your computer and use it in GitHub Desktop.
ImageMagick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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