Skip to content

Commit

Permalink
[fix] correct scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalitov committed Oct 23, 2018
1 parent ca00086 commit 6853a04
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/webapp/js/ImageUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ ImageUploader.prototype.handleFileSelection = function(file, completionCallback)
This.scaleImage(img, completionCallback);
}
}
else{
//No rotation, just scale the image
This.scaleImage(img, completionCallback);
}
}
};
reader.readAsDataURL(file);
Expand Down Expand Up @@ -172,8 +176,8 @@ ImageUploader.prototype.scaleImage = function(img, completionCallback, orientati
//Let's find the max available width for scaled image
var ratio = canvas.width/canvas.height;
var mWidth = Math.min(this.config.maxWidth, ratio*this.config.maxHeight);
if ( (this.config.maxSize>0) && (this.config.maxSize<canvas.width*canvas.height/1000) )
mWidth = Math.min(mWidth, Math.floor(Math.sqrt(this.config.maxSize*ratio)));
if ( (this.config.maxSize>0) && (this.config.maxSize<canvas.width*canvas.height/1000000) )
mWidth = Math.min(mWidth, Math.floor(Math.sqrt(this.config.maxSize*ratio)*1000));
if ( !!this.config.scaleRatio )
mWidth = Math.min(mWidth, Math.floor(this.config.scaleRatio*canvas.width));

Expand Down

0 comments on commit 6853a04

Please sign in to comment.