diff --git a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java index 35773c3a5..ae59ef9ea 100644 --- a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java +++ b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java @@ -87,8 +87,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi //Light Blue 500 private final String DEFAULT_WIDGET_COLOR = "#03A9F4"; - private int width = 200; - private int height = 200; + private int width = 0; + private int height = 0; private Uri mCameraCaptureURI; private String mCurrentPhotoPath; @@ -610,11 +610,15 @@ private void startCropping(Activity activity, Uri uri) { configureCropperColors(options); } - UCrop.of(uri, Uri.fromFile(new File(this.getTmpDir(activity), UUID.randomUUID().toString() + ".jpg"))) - .withMaxResultSize(width, height) - .withAspectRatio(width, height) - .withOptions(options) - .start(activity); + UCrop uCrop = UCrop + .of(uri, Uri.fromFile(new File(this.getTmpDir(activity), UUID.randomUUID().toString() + ".jpg"))) + .withOptions(options); + + if (width > 0) { + uCrop.withMaxResultSize(width, height).withAspectRatio(width, height); + } + + uCrop.start(activity); } private void imagePickerResult(Activity activity, final int requestCode, final int resultCode, final Intent data) { diff --git a/ios/src/ImageCropPicker.m b/ios/src/ImageCropPicker.m index 4c9d14e9e..3dde6c6ab 100644 --- a/ios/src/ImageCropPicker.m +++ b/ios/src/ImageCropPicker.m @@ -839,11 +839,7 @@ - (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect { - // we have correct rect, but not correct dimensions - // so resize image - CGSize resizedImageSize = CGSizeMake([[[self options] objectForKey:@"width"] intValue], [[[self options] objectForKey:@"height"] intValue]); - UIImage *resizedImage = [croppedImage resizedImageToFitInSize:resizedImageSize scaleIfSmaller:YES]; - ImageResult *imageResult = [self.compression compressImage:resizedImage withOptions:self.options]; + ImageResult *imageResult = [self.compression compressImage:croppedImage withOptions:self.options]; NSString *filePath = [self persistFile:imageResult.data]; if (filePath == nil) {