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.

ImageManipulator manipulateAsync Crop is not working on Android SDK 32.0.0

See original GitHub issue

🐛 Bug Report

ImageManipulator.manipulateAsync passing Crop function with valid parameter is throwing error: "Invalid crop options has been passed. Please make sure the requested crop rectangle is inside source image."

Environment

  Expo CLI 2.10.1 environment info:
    System:
      OS: Windows 10
    Binaries:
      Yarn: 1.13.0 - C:\Users\tirad\AppData\Roaming\npm\yarn.CMD
      npm: 6.7.0 - C:\Program Files\nodejs\npm.CMD

Targeting Android on Expo App Current Issue found running on a Samsung S8+ and Samsung J2 Prime

Steps to Reproduce

Take picture using the following Snack:

https://snack.expo.io/@johnnietirado/android-crop-camera-issue

  1. Click Camera Button, accept use of Camera.
  2. Click Button at bottom of screen.
  3. Original Image will be shown but not cropped correctly.

Expected Behavior

Image should be cropped correctly like a card. About a third of the height of the image and grabbing the center third.

Actual Behavior

Image is not cropped and error is thrown

Error: "Invalid crop options has been passed. Please make sure the requested crop rectangle is inside source image." in h@/data/user/0/host.exp.exponent/files/32.0.0/cached-bundle-experience-%40johnnietirado%2Fandroid-crop-camera-issue281302753-32.0.0:38:1566 << /data/user/0/host.exp.exponent/files/32.0.0/cached-bundle-experience-%40johnnietirado%2Fandroid-crop-camera-issue281302753-32.0.0:38:960 << value@/data/user/0/host.exp.exponent/files/32.0.0/cached-bundle-experience-%40johnnietirado%2Fandroid-crop-camera-issue281302753-32.0.0:46:3650 << /data/user/0/host.exp.exponent/files/32.0.0/cached-bundle-experience-%40johnnietirado%2Fandroid-crop-camera-issue281302753-32.0.0:46:1155 ...

Reproducible Demo

https://snack.expo.io/@johnnietirado/android-crop-camera-issue

Notes

I found where the error is being throw in the code: File

Line 121 has the logic which checks for correct dimensions

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MasonBergstromcommented, Apr 14, 2019

I’m getting this also. Looks like it’s some sort of multiply by 2 issue.

I was able to work around it by dividing originX, originY, width and, height all by 2.

let cropped = await ImageManipulator.manipulateAsync(photo.uri, [
    {
        crop: {
            originX: ((photo.width * .05) / 2),
            originY: ((photo.height * .4) / 2),
            width: ((photo.width * .9) / 2),
            height: ((photo.height * .2) / 2)
        }
    }
]);

This gives me 90% width and 20% height with it being centered on the original photo.

1reaction
AdamJNavarrocommented, Mar 27, 2019

You make a good point. We’ve been tracking it internally but we should definitely do a better job of making sure bugs are publicly known and can be followed along by the public. We usually try to make sure most things that can be public-facing are but I fell short here haha. I’ll be sure to ping you when we have an update on the fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImageManipulator Error on Android (SDK 32) - Expo Forums
I'm trying to crop an image (50% in the example above). It's pretty straight forward. Select an image from your camera roll and...
Read more >
expo-image-manipulator won't take uri from expo-image-picker
I want to use the expo-image-manipulator to resize the image prior to sending it to the backend but the expo imageManipulator will not...
Read more >
CHANGELOG.md · 熊刚/Expo - Gitee.com
Changelog. This is the log of notable changes to the Expo client that are developer-facing. Package-specific changes not released in any SDK will...
Read more >
@expo/config-plugins | Yarn - Package Manager
This is the log of notable changes to the Expo client that are developer-facing. Package-specific changes not released in any SDK will be...
Read more >
react native doctor android studio not found - You.com
The problem is a little clear, it's occurring because the flutter is not founding the path for your Android SDK. There are two...
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