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)
The width and height of the returned images is the same as the given width and height props.
Images are not resized to given height and width prop.
Indicate a width and height prop
Choose an image or take a photo in iOS
Crop the image (or not) and finish your edit
Look at the returned image width and height
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.