From 4e4a583d9dbdfb82a2c70bcd242a8b331d2f7702 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 8 Aug 2014 17:30:37 -0400 Subject: [PATCH] took out the meta config check from image.js --- src/controllers/accounts.js | 8 ++++++-- src/image.js | 6 ++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/controllers/accounts.js b/src/controllers/accounts.js index 0c906e562c..f2be462147 100644 --- a/src/controllers/accounts.js +++ b/src/controllers/accounts.js @@ -404,7 +404,11 @@ accountsController.uploadPicture = function (req, res, next) { image.resizeImage(req.files.userPhoto.path, extension, 128, 128, next); }, function(next) { - image.convertImageToPng(req.files.userPhoto.path, extension, next); + if (parseInt(meta.config['profile:convertProfileImageToPNG'], 10) === 1) { + image.convertImageToPng(req.files.userPhoto.path, extension, next); + } else { + next(); + } }, function(next) { user.getUidByUserslug(req.params.userslug, next); @@ -450,7 +454,7 @@ accountsController.uploadPicture = function (req, res, next) { return plugins.fireHook('filter:uploadImage', req.files.userPhoto, done); } - var convertToPNG = parseInt(meta.config['profile:convertProfileImageToPNG'], 10); + var convertToPNG = parseInt(meta.config['profile:convertProfileImageToPNG'], 10) === 1; var filename = updateUid + '-profileimg' + (convertToPNG ? '.png' : extension); user.getUserField(updateUid, 'uploadedpicture', function (err, oldpicture) { diff --git a/src/image.js b/src/image.js index 73bb85599d..0b2cea24cb 100644 --- a/src/image.js +++ b/src/image.js @@ -1,8 +1,7 @@ 'use strict'; var fs = require('fs'), - gm = require('gm').subClass({imageMagick: true}), - meta = require('./meta'); + gm = require('gm').subClass({imageMagick: true}); var image = {}; @@ -28,8 +27,7 @@ image.resizeImage = function(path, extension, width, height, callback) { }; image.convertImageToPng = function(path, extension, callback) { - var convertToPNG = parseInt(meta.config['profile:convertProfileImageToPNG'], 10); - if(convertToPNG && extension !== '.png') { + if(extension !== '.png') { gm(path).toBuffer('png', function(err, buffer) { if (err) { return callback(err);