From c25835c63edf1dca0cd282cc468f41a211a4c557 Mon Sep 17 00:00:00 2001 From: David Hoff Date: Wed, 5 Mar 2014 13:59:59 -0500 Subject: [PATCH 1/5] Remove text --- public/templates/home.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/home.tpl b/public/templates/home.tpl index dac82f3a8f..4c51578cbe 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,7 +1,7 @@ From 58cb51bb028d279d2338f00cb6dcdafaed8ad16e Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 5 Mar 2014 20:37:31 -0500 Subject: [PATCH 2/5] removed unused imagemagick require --- src/routes/user.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/routes/user.js b/src/routes/user.js index 136473ce1b..641404f8a6 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -3,7 +3,6 @@ var fs = require('fs'), winston = require('winston'), nconf = require('nconf'), async= require('async'), - imagemagick = require('node-imagemagick'), user = require('./../user'), posts = require('./../posts'), From 096f352c82d107a0b137e48cdca8c32a3415bcff Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 5 Mar 2014 23:00:27 -0500 Subject: [PATCH 3/5] closes #1130 --- package.json | 2 +- src/image.js | 36 ++++++++++++++---------------------- src/routes/user.js | 4 ++++ 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 083db7f7a0..79d2d26c33 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "less-middleware": "0.1.12", "marked": "0.2.8", "async": "~0.2.8", - "node-imagemagick": "0.1.8", + "gm": "1.14.2", "gravatar": "1.0.6", "nconf": "~0.6.7", "sitemap": "~0.7.1", diff --git a/src/image.js b/src/image.js index 97bb237a16..5f92773fa8 100644 --- a/src/image.js +++ b/src/image.js @@ -1,6 +1,7 @@ +'use strict'; var fs = require('fs'), - imagemagick = require('node-imagemagick'), + gm = require('gm').subClass({imageMagick: true}), meta = require('./meta'); var image = {}; @@ -11,35 +12,26 @@ image.resizeImage = function(path, extension, width, height, callback) { } if(extension === '.gif') { - imagemagick.convert([ - path, - '-coalesce', - '-repage', - '0x0', - '-crop', - width+'x'+height+'+0+0', - '+repage', - path - ], done); + gm().in(path) + .in('-coalesce') + .in('-resize') + .in(width+'x'+height) + .write(path, done); } else { - imagemagick.crop({ - srcPath: path, - dstPath: path, - width: width, - height: height - }, done); + gm(path) + .crop(width, height, 0, 0) + .write(path, done); } }; image.convertImageToPng = function(path, extension, callback) { var convertToPNG = parseInt(meta.config['profile:convertProfileImageToPNG'], 10); if(convertToPNG && extension !== '.png') { - imagemagick.convert([path, 'png:-'], function(err, stdout) { - if(err) { + gm(path).toBuffer('png', function(err, buffer) { + if (err) { return callback(err); } - - fs.writeFile(path, stdout, 'binary', callback); + fs.writeFile(path, buffer, 'binary', callback); }); } else { callback(); @@ -50,6 +42,6 @@ image.convertImageToBase64 = function(path, callback) { fs.readFile(path, function(err, data) { callback(err, data ? data.toString('base64') : null); }); -} +}; module.exports = image; \ No newline at end of file diff --git a/src/routes/user.js b/src/routes/user.js index 641404f8a6..db25182b2a 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -116,6 +116,7 @@ var fs = require('fs'), var uploadSize = parseInt(meta.config.maximumProfileImageSize, 10) || 256; if (req.files.userPhoto.size > uploadSize * 1024) { + fs.unlink(req.files.userPhoto.path); return res.send({ error: 'Images must be smaller than ' + uploadSize + ' kb!' }); @@ -123,6 +124,7 @@ var fs = require('fs'), var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif']; if (allowedTypes.indexOf(req.files.userPhoto.type) === -1) { + fs.unlink(req.files.userPhoto.path); return res.send({ error: 'Allowed image types are png, jpg and gif!' }); @@ -130,6 +132,7 @@ var fs = require('fs'), var extension = path.extname(req.files.userPhoto.name); if (!extension) { + fs.unlink(req.files.userPhoto.path); return res.send({ error: 'Error uploading file! Error : Invalid extension!' }); @@ -184,6 +187,7 @@ var fs = require('fs'), } if(err) { + fs.unlink(req.files.userPhoto.path); return res.send({error:err.message}); } From 6f8ed7f07377f7bccd323af3fdea6cd4cfc86cd3 Mon Sep 17 00:00:00 2001 From: Anthony Webb Date: Thu, 6 Mar 2014 00:07:07 -0600 Subject: [PATCH 4/5] err doesnt exist here --- src/upgrade.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/upgrade.js b/src/upgrade.js index 9221d29cd0..4005276cc1 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -203,11 +203,7 @@ Upgrade.upgrade = function(callback) { } else { winston.info('[2014/2/20] Activating NodeBB Essential Widgets - skipped'); - if (err) { - next(err); - } else { - Upgrade.update(thisSchemaDate, next); - } + Upgrade.update(thisSchemaDate, next); } }, function(next) { From 21b1bc1729335aa58c85696c32a2fd3efdde9d03 Mon Sep 17 00:00:00 2001 From: Anthony Webb Date: Thu, 6 Mar 2014 00:13:13 -0600 Subject: [PATCH 5/5] Revert "Remove text" This reverts commit c25835c63edf1dca0cd282cc468f41a211a4c557. --- public/templates/home.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 4c51578cbe..dac82f3a8f 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,7 +1,7 @@