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

Issue 328 ios fix image loading using uri or path #381

Merged
merged 6 commits into from
Aug 22, 2023

Conversation

taboulot
Copy link
Contributor

@taboulot taboulot commented Aug 21, 2023

Problem

This fix the issue #328.
iOS was only accepted uriusing scheme file://. This is a regression from version < 3.x.x.

Solution

The solution was to use the React-Native url converter & image loader in order to handle both path & uri (with several protocol/scheme).

Test

This PR also add several image sources in the example application using:

  • react-native-image-picker;
  • react-native-vision-camera;
  • @react-native-camera-roll/camera-roll;
  • simple url (i.e. http://.....);
ios android
New arch OFF https://github.com/bamlab/react-native-image-resizer/assets/9041221/2813ed1c-7929-45f1-9464-336a24f989c0 https://github.com/bamlab/react-native-image-resizer/assets/9041221/c519f3b9-e297-45e0-bd8b-1e6bbfe13c39
New arch ON https://github.com/bamlab/react-native-image-resizer/assets/9041221/cdd72618-9cca-44ac-a9b0-8cd2a92fd768 https://github.com/bamlab/react-native-image-resizer/assets/9041221/4b2c5f8a-3edd-4ad0-81f9-6c4daa9d4d5f

@taboulot taboulot force-pushed the issue-328-ios-fix-image-loading-using-uri-or-path branch from de607fc to 8d707ac Compare August 21, 2023 15:45
@taboulot taboulot marked this pull request as ready for review August 21, 2023 15:45
README.md Outdated
@@ -90,6 +95,9 @@ The promise resolves with an object containing: `path`, `uri`, `name`, `size` (b
| keepMeta | If `true`, will attempt to preserve all file metadata/exif info, except the orientation value since the resizing also does rotation correction to the original image. Defaults to `false`, which means all metadata is lost. Note: This can only be `true` for `JPEG` images which are loaded from the file system (not Web). |
| options.mode | Similar to [react-native Image's resizeMode](https://reactnative.dev/docs/image#resizemode): either `contain` (the default), `cover`, or `stretch`. `contain` will fit the image within `width` and `height`, preserving its ratio. `cover` preserves the aspect ratio, and makes sure the image is at least `width` wide or `height` tall. `stretch` will resize the image to exactly `width` and `height`. |
| options.onlyScaleDown | If `true`, will never enlarge the image, and will only make it smaller. |
# Limitations

- If you are using `@react-native-camera-roll/camera-roll` **with new architecture enabled this library is not going to work**. If you try to display an image with the `uri` of the library using `<Image />` you are going to have the following error: `No suitable image URL loader found for ph://...`. This error come from the ReactNative `ImageLoader`, which is the one we are currently using. Help/PR for solving this are welcome.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the alternative?

Copy link
Contributor Author

@taboulot taboulot Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment using react-native-image-picker.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inside @react-native-camera-roll/camera-roll you have a util method that permit to load ph images and convert them into local images

@jcalixte jcalixte self-requested a review August 22, 2023 08:31
@taboulot taboulot force-pushed the issue-328-ios-fix-image-loading-using-uri-or-path branch from 8d707ac to 78d4350 Compare August 22, 2023 08:35
@taboulot taboulot added this to the 3.0.6 milestone Aug 22, 2023
@taboulot taboulot merged commit bb04979 into master Aug 22, 2023
@taboulot taboulot deleted the issue-328-ios-fix-image-loading-using-uri-or-path branch August 22, 2023 08:38
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

Successfully merging this pull request may close these issues.

None yet

3 participants