browser-image-resizer
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -68,3 +68,3 @@ 'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default = | ||
if (canvas.width > maxWidth) { | ||
canvas = scaleCanvasWithAlgorithm(canvas, config); | ||
canvas = scaleCanvasWithAlgorithm(canvas, Object.assign(config, { outputWidth: maxWidth })); | ||
} | ||
@@ -80,3 +80,3 @@ | ||
var ratio = canvas.width / canvas.height; | ||
var mWidth = Math.min(config.maxWidth, ratio * config.maxHeight); | ||
var mWidth = Math.min(canvas.width, config.maxWidth, ratio * config.maxHeight); | ||
if ( | ||
@@ -88,3 +88,3 @@ config.maxSize > 0 && | ||
mWidth, | ||
Math.floor(Math.sqrt(config.maxSize * ratio))); | ||
Math.floor(config.maxSize * 1000 / canvas.height)); | ||
@@ -194,3 +194,3 @@ if (!!config.scaleRatio) | ||
var scale = config.maxWidth / canvas.width; | ||
var scale = config.outputWidth / canvas.width; | ||
@@ -197,0 +197,0 @@ scaledCanvas.width = canvas.width * scale; |
{ | ||
"name": "browser-image-resizer", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "A browser-based utility to downscale and resize images using <canvas>", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -68,3 +68,3 @@ import EXIF from './exif'; | ||
if (canvas.width > maxWidth) { | ||
canvas = scaleCanvasWithAlgorithm(canvas, config); | ||
canvas = scaleCanvasWithAlgorithm(canvas, Object.assign(config, { outputWidth: maxWidth })); | ||
} | ||
@@ -80,3 +80,3 @@ | ||
var ratio = canvas.width / canvas.height; | ||
var mWidth = Math.min(config.maxWidth, ratio * config.maxHeight); | ||
var mWidth = Math.min(canvas.width, config.maxWidth, ratio * config.maxHeight); | ||
if ( | ||
@@ -88,3 +88,3 @@ config.maxSize > 0 && | ||
mWidth, | ||
Math.floor(Math.sqrt(config.maxSize * ratio)) | ||
Math.floor(config.maxSize * 1000 / canvas.height) | ||
); | ||
@@ -194,3 +194,3 @@ if (!!config.scaleRatio) | ||
var scale = config.maxWidth / canvas.width; | ||
var scale = config.outputWidth / canvas.width; | ||
@@ -197,0 +197,0 @@ scaledCanvas.width = canvas.width * scale; |
160929
8