From e7bb464f32e2c034e885a5a72dc5b59b7826c926 Mon Sep 17 00:00:00 2001 From: achauchet Date: Wed, 25 Oct 2017 10:14:20 +0200 Subject: [PATCH] Check getImage options on android --- src/imagepicker.android.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 770f391..3c7c1b7 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -208,12 +208,16 @@ export class SelectedAsset extends imageAssetModule.ImageAsset { // TODO: Refactor to accomodate different scaling options // Right now, it just selects the smallest of the two sizes // and scales the image proportionally to that. - let targetSize = options.maxWidth < options.maxHeight ? options.maxWidth : options.maxHeight; - while (!(this.matchesSize(targetSize, outWidth) || - this.matchesSize(targetSize, outHeight))) { - outWidth /= 2; - outHeight /= 2; - scale *= 2; + let targetSize = !options.maxWidth && options.maxHeight ? options.maxHeight : + (!options.maxHeight && options.maxWidth ? options.maxWidth : + (options.maxWidth < options.maxHeight ? options.maxWidth : options.maxHeight)); + if (targetSize) { + while (!(this.matchesSize(targetSize, outWidth) || + this.matchesSize(targetSize, outHeight))) { + outWidth /= 2; + outHeight /= 2; + scale *= 2; + } } } return scale;