Skip to content

Commit

Permalink
Merge pull request RocketChat#11009 from RocketChat/fix.10483
Browse files Browse the repository at this point in the history
[FIX] Exception thrown on avatar validation
  • Loading branch information
engelgabriel authored Jun 5, 2018
2 parents 2218753 + d6c9beb commit 5565503
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/rocketchat-file-upload/server/lib/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ Object.assign(FileUpload, {
s.rotate();
// Get metadata to resize the image the first time to keep "inside" the dimensions
// then resize again to create the canvas around

s.metadata(Meteor.bindEnvironment((err, metadata) => {
if (!metadata) {
metadata = {};
}

s.toFormat(sharp.format.jpeg)
.resize(Math.min(height, metadata.width), Math.min(height, metadata.height))
.resize(Math.min(height || 0, metadata.width || Infinity), Math.min(height || 0, metadata.height || Infinity))
.pipe(sharp()
.resize(height, height)
.background('#FFFFFF')
Expand Down

0 comments on commit 5565503

Please sign in to comment.