From 569b069a03cf99d599cdee8e685935a706046cf4 Mon Sep 17 00:00:00 2001 From: Fares Hantous Date: Sat, 8 Oct 2016 21:49:21 +0100 Subject: [PATCH 1/2] prevent the creation of picture bigger than original for ios --- src/ios/UIImage+CropScaleOrientation.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ios/UIImage+CropScaleOrientation.m b/src/ios/UIImage+CropScaleOrientation.m index a66a5d88d..c31335635 100644 --- a/src/ios/UIImage+CropScaleOrientation.m +++ b/src/ios/UIImage+CropScaleOrientation.m @@ -28,8 +28,8 @@ - (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize CGSize imageSize = sourceImage.size; CGFloat width = imageSize.width; CGFloat height = imageSize.height; - CGFloat targetWidth = targetSize.width; - CGFloat targetHeight = targetSize.height; + CGFloat targetWidth = MIN(targetSize.width, width); + CGFloat targetHeight = MIN(targetSize.height, height); CGFloat scaleFactor = 0.0; CGFloat scaledWidth = targetWidth; CGFloat scaledHeight = targetHeight; @@ -136,8 +136,8 @@ - (UIImage*)imageByScalingNotCroppingForSize:(CGSize)targetSize CGSize imageSize = sourceImage.size; CGFloat width = imageSize.width; CGFloat height = imageSize.height; - CGFloat targetWidth = targetSize.width; - CGFloat targetHeight = targetSize.height; + CGFloat targetWidth = MIN(targetSize.width, width); + CGFloat targetHeight = MIN(targetSize.height, height); CGFloat scaleFactor = 0.0; CGSize scaledSize = targetSize; From 67755254fca55bd1a6ea1a38ebb835cf972617db Mon Sep 17 00:00:00 2001 From: Fares Hantous Date: Sat, 8 Oct 2016 21:49:38 +0100 Subject: [PATCH 2/2] prevent the creation of picture bigger than original for android --- src/android/CameraLauncher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java index 69cb5db7b..23b225eca 100644 --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -1076,8 +1076,8 @@ private Bitmap getScaledAndRotatedBitmap(String imageUrl) throws IOException { * @return */ public int[] calculateAspectRatio(int origWidth, int origHeight) { - int newWidth = this.targetWidth; - int newHeight = this.targetHeight; + int newWidth = Math.min(this.targetWidth, origWidth); + int newHeight = Math.min(this.targetHeight, origHeight); // If no new width or height were specified return the original bitmap if (newWidth <= 0 && newHeight <= 0) {