question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] ImageResizer / Message: Image uri invalid

See original GitHub issue

I use the following uri (obtained from camera): /var/mobile/Containers/Data/Application/6DCA648B-3E9E-4535-AC2C-20AA90F17681/Library/Caches/RNRectangleScanner/O1663320548.jpeg

imageWidth and imageHeight are set properly. Rotation is set to multiples of 90 (0, 90, 180 or 270).

But when I call

    createResizedImage(this.props.imageUri, imageWidth, imageHeight, 'JPEG', 100, this.state.rotation, undefined, false, {
      mode: 'stretch',
      onlyScaleDown: true,
    })

I get the following error: IMG_20220916_123501

What could cause this? Why the uri is considered invalid? Same happens when I try to use a remote uri. On android it works perfectly.

"@bam.tech/react-native-image-resizer": "^3.0.0",
"react": "17.0.2",
"react-native": "0.68.2"

EDIT: I tried to add “file://” at the beginning of the uri and it did not crash anymore. But the resulted image is not as expected when rotation is different from 0. On android works perfectly also with rotation.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
taboulotcommented, Oct 6, 2022

Hi folks 👋

Indeed I introduced a regression during the migration.

I do not feel comfortable with how you access files on iOS. The difference between path, URL, etc… is not crystal clear in my mind.

I think this should help to support both path and URI : https://gist.github.com/taboulot/2a56c43dd27479c31beb2066a1f803cd

I have tested it in the example project, which uses URI, and it works well. @ggunti Can you apply this patch on your project that use path and tell me if it fixes the problem?

0reactions
nofacezcommented, Dec 14, 2022

Updated to 3.0.4 and faced the same issue. Trying to resize photos taken with react-native-vision-camera results in an ‘Image uri invalid’ error. Image path starts with /private/var/mobile.... Adding file:// before it fixes the issue. Is this a problem with resizer or camera?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · bamlab/react-native-image-resizer - GitHub
Contribute to bamlab/react-native-image-resizer development by creating an account on GitHub. ... [iOS] ImageResizer / Message: Image uri invalid.
Read more >
ImageResizer simply not resizing images - Stack Overflow
In the troubleshooting page for the ImageResizer, it is stated that if an image cannot be resized, it could be one of the...
Read more >
Top 5 react-native-image-resizer Code Examples - Snyk
To help you get started, we've selected a few react-native-image-resizer examples, based on popular ways it is used in public projects.
Read more >
react-native-image-resizer - npm
A React Native module that can create scaled versions of local images (also supports the assets library on iOS). react-native, react-native- ...
Read more >
problem to load the source and recover the width and height ...
Hi,. We use this package to resize an image before sending it to a visual search engine. The source is still existing but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found