Merge branch 'extract-gravatar'

v1.18.x
Julian Lam 10 years ago
commit f1c422d190

@ -28,7 +28,7 @@
"daemon": "~1.1.0", "daemon": "~1.1.0",
"express": "^4.9.5", "express": "^4.9.5",
"express-session": "^1.8.2", "express-session": "^1.8.2",
"gm": "1.17.0", "lwip": "0.0.6",
"gravatar": "^1.1.0", "gravatar": "^1.1.0",
"heapdump": "^0.3.0", "heapdump": "^0.3.0",
"less": "^2.0.0", "less": "^2.0.0",

@ -1,41 +1,48 @@
'use strict'; 'use strict';
var fs = require('fs'), var fs = require('fs'),
gm = require('gm').subClass({imageMagick: true}); lwip = require('lwip'),
plugins = require('./plugins');
var image = {}; var image = {};
image.resizeImage = function(path, extension, width, height, callback) { image.resizeImage = function(path, extension, width, height, callback) {
function done(err, stdout, stderr) { if (plugins.hasListeners('filter:image.resize')) {
callback(err); plugins.fireHook('filter:image.resize', {
} path: path,
extension: extension,
if(extension === '.gif') { width: width,
gm().in(path) height: height
.in('-coalesce') }, function(err, data) {
.in('-resize') callback(err);
.in(width+'x'+height+'^') });
.write(path, done);
} else { } else {
gm(path) lwip.open(path, function(err, image) {
.in('-resize') image.batch()
.in(width+'x'+height+'^') .cover(width, height)
.gravity('Center') .crop(width, height)
.crop(width, height) .writeFile(path, function(err) {
.write(path, done); callback(err)
})
});
} }
}; };
image.convertImageToPng = function(path, extension, callback) { image.normalise = function(path, extension, callback) {
if(extension !== '.png') { if (plugins.hasListeners('filter:image.normalise')) {
gm(path).toBuffer('png', function(err, buffer) { plugins.fireHook('filter:image.normalise', {
path: path,
extension: extension
}, function(err, data) {
callback(err);
});
} else {
lwip.open(path, function(err, image) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
fs.writeFile(path, buffer, 'binary', callback); image.writeFile(path, 'png', callback)
}); });
} else {
callback();
} }
}; };

@ -57,7 +57,7 @@ module.exports = function(Plugins) {
function display() { function display() {
process.stdout.write('\n'); process.stdout.write('\n');
winston.warn('[plugins/' + pluginData.id + '] This plugin may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing.'); winston.warn('[plugins/' + pluginData.id + '] This plugin may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing.');
winston.warn('[plugins/' + pluginData.id + '] In the event of an unresponsive NodeBB caused by this plugin, run ./nodebb reset plugin="' + pluginData.id + '".'); winston.warn('[plugins/' + pluginData.id + '] In the event of an unresponsive NodeBB caused by this plugin, run ./nodebb reset -p ' + pluginData.id + '.');
process.stdout.write('\n'); process.stdout.write('\n');
} }

@ -41,7 +41,7 @@ module.exports = function(User) {
}, },
function(next) { function(next) {
if (convertToPNG) { if (convertToPNG) {
image.convertImageToPng(picture.path, extension, next); image.normalise(picture.path, extension, next);
} else { } else {
next(); next();
} }

Loading…
Cancel
Save