React-native-image-crop-picker: [iOS] Images are not resized to given width and height prop after cropping

Created on 2 Oct 2018  Â·  9Comments  Â·  Source: ivpusic/react-native-image-crop-picker

Hi, I noticed that after the update 0.21.2, cropped images are not resized to the given height and width props (only iOS). The images keep their height and width and therefore most of the images are too big to upload to a server.

After further investigation, I realized that the following change (in _ios/src/ImageCropPicker.m_) caused this issue:

https://github.com/ivpusic/react-native-image-crop-picker/pull/825/files#diff-ae20f589f1a9014f341c1ab93989eab1

The changes were made to avoid cropping the image twice, but as far as I can tell it causes this new bug. Undoing these changes solves the issue, but it would be great if this issue could be fixed in the main project.

(another completely different issue that I noticed: https://github.com/ivpusic/react-native-image-crop-picker/issues/844)

Version

  • react-native-image-crop-picker v0.21.2
  • react-native v0.55.4

Platform

  • iOS

Expected behaviour

The width and height of the returned images is the same as the given width and height props.

Actual behaviour

Images are not resized to given height and width prop.

Steps to reproduce

  1. Indicate a width and height prop

  2. Choose an image or take a photo in iOS

  3. Crop the image (or not) and finish your edit

  4. Look at the returned image width and height

All 9 comments

Having this problem too. How did you fix? Modifying the ios/src/ImageCropPicker.m

Adding back

// 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];

Yes this was also my approach.

Found out i was using .sourceURL instead of .path which is the tmp cropped
version. Might help.

On Thu, Oct 4, 2018 at 3:12 PM Lowisoft notifications@github.com wrote:

Yes this was also my approach.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/ivpusic/react-native-image-crop-picker/issues/843#issuecomment-427034465,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AatGkKD__HmHBuM0uH-WfDi07CSodITxks5uhhdUgaJpZM4XEZO3
.

--

—

Leo Mercier | Co-Founder

[email protected] leo@crowdform.co.uk

m : +44 <+44%2020%208050%201506> (0)782 5507452 <07825507452>
t : +44 (0)20 8050 1506 <+44%2020%208050%201506>

25 Holywell Row, London, EC2A 4XE

--

Unfortunately not as I am using .data to get base64 of the image.

As someone who was seeing this as well when I switched from image.sourceUrl to image.path it fixed me and probably could be closed.

Can confirm the issue and that the cause is the suggested PR #825

@leomercier / Everyone else

I found that you have to set the compressImageMax... values for iOS to correctly return the resized image.

Sample code:

ImagePicker.openCamera({
      width: 500,
      height: 500,
      compressImageMaxWidth: 500,
      compressImageMaxHeight: 500,
      cropping: true,
    }).then(image => {
      this.uploadImageBackground(image.path)
    }).catch((err) => { console.log("openCamera catch" + err.toString()) });

@KevinColemanInc that didn't work for me --- reverting to the pre #834 change solves the issue

Late to the party here.. was there a fix for this?
All I'm trying to do is open an image picker, select a photo, croppable and can be made light to save.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cwRichardKim picture cwRichardKim  Â·  3Comments

fmcruz picture fmcruz  Â·  3Comments

tximpa91 picture tximpa91  Â·  3Comments

phantom1299 picture phantom1299  Â·  3Comments

zhangjunhou picture zhangjunhou  Â·  3Comments