mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
imagemagick resizing
This commit is contained in:
@@ -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": {},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user