react-native-image-resizer
react-native-image-resizer copied to clipboard
Random hangs in iOS
ImageResizer.createResizedImage randomly hangs in my app with no error output about 30% of the times I run my code, forcing the user to have to completely terminate the app and restart (because user interaction was disabled while image compression was happening which should only take a second anyway). This alternative works much much better for me so far: https://github.com/nomi9995/react-native-image-compressor (though a critical note of that library is maxWidth only works for landscape and maxHeight only works for portrait images)
This was my code:
var resized = await ImageResizer.createResizedImage(Platform.OS === 'android' ? 'file://' + RNFS.ExternalDirectoryPath + '/' + i + '.jpg' : RNFS.LibraryDirectoryPath + '/' + i + '.jpg', 1024, picHeights[i], 'JPEG', 30, 0, undefined, true, {onlyScaleDown: true, resizeMode: 'cover'}).then(response => {
console.log('Got response')
})
.catch(err => {
console.log('Got error')
})
iPhone 13 (simulator), iOS 15.0, RN 0.66.0