react-native-compressor icon indicating copy to clipboard operation
react-native-compressor copied to clipboard

Gracefully handle non-image files for getImageMetaData (currently crashes the app on iOS)

Open ChristopherGabba opened this issue 1 year ago • 1 comments

Current behavior

Currently if you feed a file that is not an image into getImageMetaData, the app hard crashes. I was using this function to test if a url was an image or not.

export async function isValidImage(url: string) {
  try {
    // Check if the fetched data is an image
      const imageData = await getImageMetaData(url)
      return imageData.extension !== "unknown"Ï
  } catch (error) {
    console.log("IMAGE ERROR", error)
    return false
  }
}

Expected behavior

The function returns an extension of "unknown".

Platform

Works on android but not on iOS.

React Native Version

"react-native": "0.73.6",

React Native Compressor Version

"react-native-compressor": "^1.8.23",

Reproducible Steps And Demo

Simply feed this url into the getImageMetaData function: https://www.instagram.com/reel/C49E_fuvM90/

ChristopherGabba avatar Apr 04 '24 14:04 ChristopherGabba

👋 @ChristopherGabba Thanks for opening your issue here! If you find this package useful hit the star🌟!

github-actions[bot] avatar Apr 04 '24 14:04 github-actions[bot]

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 05 '25 02:04 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Apr 12 '25 02:04 github-actions[bot]