Skip to content

Commit

Permalink
added filter:image.size
Browse files Browse the repository at this point in the history
fix uploading of gifs if imagemagick plugin is installed but no image
upload plugins are present.
  • Loading branch information
barisusakli committed May 9, 2016
1 parent bc03594 commit acc030e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/controllers/uploads.js
Expand Up @@ -83,7 +83,7 @@ function resizeImage(fileObj, callback) {
function(next) {
fullPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), '..', fileObj.url);

image.load(fullPath, next);
image.size(fullPath, next);
},
function (imageData, next) {
if (imageData.width < parseInt(meta.config.maximumImageWidth, 10) || 760) {
Expand Down
18 changes: 13 additions & 5 deletions src/image.js
Expand Up @@ -94,11 +94,19 @@ image.normalise = function(path, extension, callback) {
}
};

image.load = function(path, callback) {
new Jimp(path, function(err, data) {
callback(err, data ? data.bitmap : null);
});
};
image.size = function(path, callback) {
if (plugins.hasListeners('filter:image.size')) {
plugins.fireHook('filter:image.size', {
path: path,
}, function(err, image) {
callback(err, image);
});
} else {
new Jimp(path, function(err, data) {
callback(err, data ? data.bitmap : null);
});
}
}

image.convertImageToBase64 = function(path, callback) {
fs.readFile(path, function(err, data) {
Expand Down

0 comments on commit acc030e

Please sign in to comment.