diff --git a/src/windows/CameraProxy.js b/src/windows/CameraProxy.js index 5ad9475..505d3d8 100644 --- a/src/windows/CameraProxy.js +++ b/src/windows/CameraProxy.js @@ -93,8 +93,10 @@ function resizeImage(successCallback, errorCallback, file, targetWidth, targetHe var image = new Image(); image.src = imageData; image.onload = function() { - var imageWidth = targetWidth, - imageHeight = targetHeight; + var ratio = Math.min(targetWidth / this.width, targetHeight / this.height); + var imageWidth = ratio * this.width; + var imageHeight = ratio * this.height; + var canvas = document.createElement('canvas'); var storageFileName; @@ -134,8 +136,9 @@ function resizeImageBase64(successCallback, errorCallback, file, targetWidth, ta image.src = imageData; image.onload = function() { - var imageWidth = targetWidth, - imageHeight = targetHeight; + var ratio = Math.min(targetWidth / this.width, targetHeight / this.height); + var imageWidth = ratio * this.width; + var imageHeight = ratio * this.height; var canvas = document.createElement('canvas'); canvas.width = imageWidth;