mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-04 21:15:55 +01:00
imagemagick resizing
This commit is contained in:
@@ -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