secret
Last active

Back link: http://stackoverflow.com/questions/14757336/merge-two-images-with-nodejs-and-graphicsmagick/14758251 Run this code when the form is submitted, This part of code assumes gm and req.files.image exist

  • Download Gist
thumb.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
var gm = require('gm');
var imageMagick = gm.subClass({ imageMagick: true });
 
imageMagick(req.files.image.path)
.gravity('Center')
.background('black')
.extent(450, 225)
.stream(function (err, stdout, stderr){
if( stdout ){
cdn.saveStream(
cdnCompany,
fileName.name+'.'+fileName.ext,
stdout,
function (saveErr, imageInfo) {
console.log('big')
console.log(imageInfo);
data.imageId = uniqueId;
data.imageExt = fileName.ext;
data.companyLogo = fileName.name+'.'+fileName.ext;
cb( saveErr, imageInfo );
}
);
}
else{
cb( err);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.