From d1041bedf48c700d949bde948e0705b5b1b99907 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 15 May 2013 15:01:05 -0400 Subject: [PATCH] imagemagick resizing --- package.json | 3 ++- src/routes/user.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 69583881ff..72e0ad08c3 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "marked": "0.2.8", "bcrypt": "0.7.5", "node-gyp": "0.9.5", - "async": "0.2.8" + "async": "0.2.8", + "node-imagemagick": "0.1.8" }, "devDependencies": {}, "optionalDependencies": {}, diff --git a/src/routes/user.js b/src/routes/user.js index 7af4fa3f31..ac8fa9a1b8 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -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) {