react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

URGENT ERROR: react-native-image-crop-picker does not open after expo-image-manipulator used

Open jakeherm opened this issue 9 months ago • 3 comments

Here is a reproducible repo that contains the issue I will discuss below: https://github.com/jakeherm/image-picker-cropper-test

When I attempt to select an image or many images via expo-image-manipulator, then use react-native-image-crop-picker to crop them, the image crop picker library never opens.

This issue happens significantly less often when a 1s timeout is added, but I want to get to the bottom of the issue to solve why it is occuring.

jakeherm avatar Feb 20 '25 02:02 jakeherm

after picking image from expo-image-picker i put my cropping code in seTimeout with 1 second timer it worked fine. Thanks:

const pickImage = async () => { try { // Request permission to access media library const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync()

  if (permissionResult.granted === false) {
    alert("You've refused to allow this app to access your camera!")
    return
  }

  // Open the image picker
  const result = await ImagePicker.launchImageLibraryAsync({
    mediaTypes: ['images'],
    allowsEditing: false,
    aspect: [1, 1],
    quality: 1,
  })

  console.log('Picked image result is:', result)
  setTimeout(async () => {
    if (!result.canceled) {
      const uri = result.assets[0].uri

      try {
        // Open image cropper
        const cropped = await ImageCropPicker.openCropper({
          cropping: true,
          mediaType: 'photo',
          path: uri,
          width: 1080,
          height: 1440,
        })
        console.log('Cropped image result is:', cropped)
        // Return both original and cropped image URLs
        return {
          originalImage: uri,
          croppedImage: cropped.path,
        }
      } catch (error) {
        console.log(error)
      }
    } else {
      // Image picker canceled
      return null
    }
  }, 1000)
} catch (error) {
  console.error(error)
  return null
}

}

Arslan-Naveed avatar May 09 '25 11:05 Arslan-Naveed

There are still extreme outlier cases where it does not work. Identifying the root cause would be beneficial.

jakeherm avatar May 23 '25 11:05 jakeherm

Any updates on this? I have the same issue? It also hangs silently so it would be nice as a workaround to know whether it succeeded or not

Rezahojjati avatar Nov 13 '25 19:11 Rezahojjati