Skip to content

Commit

Permalink
Merge pull request NodeBB#15 from tosyu/issues/14-upload-orientation
Browse files Browse the repository at this point in the history
fixed image orientation on uploads
  • Loading branch information
ic3fresh committed May 5, 2018
2 parents 966d5c8 + 6fc9a26 commit 43f52fb
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/controllers/uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,26 @@ function resizeImage(fileObj, callback) {
image.size(fileObj.path, next);
},
function (imageData, next) {
if (imageData.width < (parseInt(meta.config.maximumImageWidth, 10) || 760)) {
fileObj.width = imageData.width;
fileObj.height = imageData.height;
next();
},
function (next) {
// quick fix for image orientation
// would use image.normalise but this changes the filename and
// extension and will brake regexp on frontend
// so the image is resampled with same dimensions and fixed
// orientation, depends on imagemagick plugin
image.resizeImage({
path: fileObj.path,
target: fileObj.path,
extension: path.extname(fileObj.path),
width: fileObj.width,
quality: 95,
}, next);
},
function (next) {
if (fileObj.width < (parseInt(meta.config.maximumImageWidth, 10) || 760)) {
return callback(null, fileObj);
}

Expand Down

0 comments on commit 43f52fb

Please sign in to comment.