This commit is contained in:
Bruno Windels 2020-11-26 09:49:25 +01:00
parent 1c4818cf1d
commit a9a27133b9

View file

@ -44,8 +44,8 @@ export class ImageHandle {
async scale(maxDimension) { async scale(maxDimension) {
const aspectRatio = this.width / this.height; const aspectRatio = this.width / this.height;
const scaleFactor = Math.min(1, maxDimension / (aspectRatio >= 1 ? this.width : this.height)); const scaleFactor = Math.min(1, maxDimension / (aspectRatio >= 1 ? this.width : this.height));
const scaledWidth = this.width * scaleFactor; const scaledWidth = Math.round(this.width * scaleFactor);
const scaledHeight = this.height * scaleFactor; const scaledHeight = Math.round(this.height * scaleFactor);
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
canvas.width = scaledWidth; canvas.width = scaledWidth;