imagemagick resizing

This commit is contained in:
Baris Usakli
2013-05-15 15:01:05 -04:00
parent 40b8264d6e
commit d1041bedf4
2 changed files with 15 additions and 1 deletions

View File

@@ -100,6 +100,8 @@ var user = require('./../user.js'),
var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'];
var type = req.files.userPhoto.type;
console.log(req.files.userPhoto);
if(allowedTypes.indexOf(type) === -1) {
res.send({
error: 'Allowed image types are png, jpg and gif!'
@@ -161,6 +163,17 @@ var user = require('./../user.js'),
user.setUserField(uid, 'uploadedpicture', imageUrl);
user.setUserField(uid, 'picture', imageUrl);
var im = require('node-imagemagick');
im.resize({
srcPath: global.configuration['ROOT_DIRECTORY'] + uploadPath,
dstPath: global.configuration['ROOT_DIRECTORY'] + uploadPath,
width: 128
}, function(err, stdout, stderr){
if (err)
throw err;
});
});
os.on('error', function(err) {