Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Images are not resized to given width and height prop after cropping #843

Closed
Lowisoft opened this issue Oct 2, 2018 · 9 comments
Closed

Comments

@Lowisoft
Copy link

Lowisoft commented Oct 2, 2018

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: #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

@leomercier
Copy link

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

@Lowisoft
Copy link
Author

Lowisoft commented Oct 4, 2018

Yes this was also my approach.

@leomercier
Copy link

leomercier commented Oct 4, 2018 via email

@Lowisoft
Copy link
Author

Lowisoft commented Oct 4, 2018

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

@Salinn
Copy link

Salinn commented Nov 2, 2018

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.

@aminosman
Copy link

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

@KevinColemanInc
Copy link

@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()) });

@lfkwtz
Copy link

lfkwtz commented Dec 7, 2018

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

ivpusic added a commit that referenced this issue Jan 18, 2019
* Android: Add video recording support

- Caveats:
  - Wont work if cropping is enabled
- Video recording will be used if mediaType is set to 'video'
  - Mediatype any is not supported since there is no standard intent for capture image or video

* IOS: Add video recording support

- Caveats:
  - Cropping does not work

Video recording will be enabled if mediaType is set to `video` or `any`. Note: With any the native ui
allows the user to choose whether to take a photo or record a video. This differs from android where
mediaType any will just allow taking photos.

* IOS: Set camera video quality to high

* Update README.md (#851)

* Update PickerModule.java (#862)

Fix for default values being kept when calling cropPicker from multiple locations.

Now default values if not passed will be reverted to default.

* version bump

* Add front camera support for android (#876)

* Add front camera support for android

* Update readme

* Update readme

* Update README.md

* Added missing flags to support front camera on some android phones (#891)

* Remove problematic step from manual post-install steps (#821)

* (ios) fix images are not resized after cropping. Fixes #843

* (ios) add example project xcshareddata

* (ios) fixes for camera recording. updated example project with camera recording. updated readme with camera recording

* unify ios and android camera response. Fixes #872
@rawadrifai
Copy link

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.

adylevy pushed a commit to Homeisapp/react-native-image-crop-picker that referenced this issue Nov 19, 2019
* Add chooseText and cancelText properties: rebased (ivpusic#699)

* Add cancel and choose buttons text properties

* Change props names to ‘cancelText’,’chooseText’

* Add cancel and choose buttons text props

* Fix properties names IOS

* Add cropper prefix and update readme

* Add cloud support (Android) (ivpusic#650)

* Add cloud support - workd in progress

* Fix extension issue

* Remove log, unused import

* Fix regression (MIME_TYPE for action_get_document)

* (android) Upgrade ucrop to 2.2.2. Upgrade react-native for example project. Cleanup picker module

* version bump

* (android) Result collector improvements

* version bump

* Update README.md

* Update README.md

* Update README.md

* Reduce size of default compressed files, update README (ivpusic#736)

* [fix/android] Android API version under 19 crash fix (ivpusic#741)

* Convert unknown file types to JPEG (ivpusic#735)

* Added android equivalent code to iOS code. (ivpusic#749)

* Revert "Added android equivalent code to iOS code. (ivpusic#749)" (ivpusic#750)

This reverts commit 97ce8ba.

* Added android equivalent code for skipping image compression. (ivpusic#753)

* Added android equivalent code to iOS code.

* Fix invalid variable.

* Added option to configure avoidEmptySpaceAroundImage (ivpusic#765)

* Added option to configure avoidEmptySpaceAround image

* Added missing interface option

* Fixes uncasted bool value

* Add new logo/icon (ivpusic#768)

* Upload new logo

* Add new logo to README

* Add new to mipmap hdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap mdpi

* Add new to mipmap xhdpi

* Add new to mipmap xhdpi

* Add new to mipmap xhdpi

* Add new to mipmap xhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Add new to mipmap xxhdpi

* Upload new logo svg

* Update README with new logo

* delete

* Upload New logo svg

* Update README

* Update README.md

* Use project-wide properties and new dependency (ivpusic#771)

* Support for gradle 3.+

* Add cropperToolbarTitle into TypeScript typings (ivpusic#777)

* Fix a bug when the file name contains slashes. (ivpusic#775)

It can happen when selecting an image downloaded from Weibo app.

* Change screen orientation so android will detect and change to match screen fixes issue ivpusic#733 (ivpusic#766)

* Adds forceJpg flag to convert live photos (ivpusic#791)

* Adds property to filter live photos

* Force JPG image conversion

* Renames forceJPG -> forceJpg

* [DEVOPS] version bump

* Revert to compile (ivpusic#796)

* [DEVOPS] Version bump

* add license scan

* Set options.networkAccessAllowed = YES in getVideoAsset to prevent freezing when attempting to get videos stored in the cloud (ivpusic#772)

* Fix typo on example (ivpusic#809)

* Fall back to writing to file if _data column does not exist (ivpusic#817)

* Fall back to writting to file if _data column does not exist

* Fix spelling

* Update README.md

* Update README.md (ivpusic#826)

Add optional configuration details about default ios text button for the camera and the gallery

* Diegolmello master (ivpusic#834)

* [FIX] Poor image quality after cropping

* Update README.md (ivpusic#826)

Add optional configuration details about default ios text button for the camera and the gallery

* [IMPROVEMENT] fix android cropping height condition. update podfile lock

* version bump

* Update README.md (ivpusic#851)

* Update PickerModule.java (ivpusic#862)

Fix for default values being kept when calling cropPicker from multiple locations.

Now default values if not passed will be reverted to default.

* version bump

* Add front camera support for android (ivpusic#876)

* Add front camera support for android

* Update readme

* Update readme

* Update README.md

* Added missing flags to support front camera on some android phones (ivpusic#891)

* Remove problematic step from manual post-install steps (ivpusic#821)

* (ios) fix images are not resized after cropping. Fixes ivpusic#843

* (ios) add example project xcshareddata

* (feature) video recording (ivpusic#917)

* Android: Add video recording support

- Caveats:
  - Wont work if cropping is enabled
- Video recording will be used if mediaType is set to 'video'
  - Mediatype any is not supported since there is no standard intent for capture image or video

* IOS: Add video recording support

- Caveats:
  - Cropping does not work

Video recording will be enabled if mediaType is set to `video` or `any`. Note: With any the native ui
allows the user to choose whether to take a photo or record a video. This differs from android where
mediaType any will just allow taking photos.

* IOS: Set camera video quality to high

* Update README.md (ivpusic#851)

* Update PickerModule.java (ivpusic#862)

Fix for default values being kept when calling cropPicker from multiple locations.

Now default values if not passed will be reverted to default.

* version bump

* Add front camera support for android (ivpusic#876)

* Add front camera support for android

* Update readme

* Update readme

* Update README.md

* Added missing flags to support front camera on some android phones (ivpusic#891)

* Remove problematic step from manual post-install steps (ivpusic#821)

* (ios) fix images are not resized after cropping. Fixes ivpusic#843

* (ios) add example project xcshareddata

* (ios) fixes for camera recording. updated example project with camera recording. updated readme with camera recording

* unify ios and android camera response. Fixes ivpusic#872

* version bump

* Update README.md

* Simplify `includeBase64` (ivpusic#918)

If `image.data` is already base64 encoded string, why do we need this wrapper?
The proposed change worked for me on ios and android.

* Make example config valid json (ivpusic#927)

* (android) cropping and resizing improvements

* (android) simplify options parsing

* android libs and package.json version bump

* Remove images from npm bundle (ivpusic#960)

* upgrade example project to react-native 0.59

* fix ios camera with cropping not reject on cancel cropping (ivpusic#954)

* fix ios camera with cropping not reject on cancel cropping

* cancel properly from opencropper

* replace compile with implementation in build.gradle

* version bump

* Add some types for Image interface (ivpusic#973)

* (android) add showCropFrame option (ivpusic#972)

* Fix Android image rotation issue when compressing gallery and camera images (ivpusic#379) (ivpusic#986)

When using the image compression options, the returned resized image orientation differed from the original image. This caused selected images to often be rotated.

Original issue thread:
ivpusic#379

* version bump

* example project support for android 9

* fixed bug with iOS cancel button (ivpusic#1000)

* version bump

* autoclose inputstream when base64 image file (ivpusic#1040)

* Fix when Pictures directory is not existing on device (ivpusic#1027)

* Update pod dependency to support rn 0.60 (ivpusic#1019)

* Update pod dependency to support rn 0.60

* Update RNImageCropPicker.podspec

* update android support library to androidx (ivpusic#1048)

* Update PickerModule.java

* Update RealPathUtil.java

* Update AndroidManifest.xml

* finishing support for react-native 0.60

* add installation notes for react-native 0.60

* Clarify README.md (ivpusic#1065)

React Native 0.60 higher requires you to manually install the pods after auto linking

* Clarify README.md (ivpusic#1058) (ivpusic#1074)

Not all Android devices handle useFrontCamera

* Adds a sortOrder flag to sort by creation date on iOS (ivpusic#1090)

* Adds a sortOrder flag to sort by creation date on iOS

* Removes extraneous sortOrder access

* check permission before startCropping. Fix of ivpusic#957 (ivpusic#1095)

* version bump

* Revert "Adds a sortOrder flag to sort by creation date on iOS (ivpusic#1090)"

This reverts commit 33fd526.

* version bump

* fixed `jitpack.io` url in readme.md (ivpusic#1115)

* Added iOS 13 DarkMode for picker (ivpusic#1129)

* Update README.md

* version bump

* HOM-3770 fix merge issues

* HOM-3770 restore video compression utility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants