Skip to content

Commit

Permalink
Merge pull request #16 from rvalitov/bug/scaling
Browse files Browse the repository at this point in the history
[fix] correct scaling
  • Loading branch information
rossturner authored Oct 23, 2018
2 parents 4f0a6b7 + 6853a04 commit 1591ff0
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 1591ff0

Please sign in to comment.