import ImageResizer from 'react-native-image-resizer';
ImageResizer.createResizedImage(imageUri, newWidth, newHeight, compressFormat, quality).then((resizedImageUri) => {
// resizeImageUri is the URI of the new image that can now be displayed, uploaded...
}).catch((err) => {
// Oops, something went wrong. Check that the filename is correct and
// inspect err to get more details.
});
4条答案
按热度按时间d6kp6zgx1#
如果您使用react-native-image-picker上传图像,您可以设置maxWidth、maxHeight或图像质量以减小尺寸。
h79rfbju2#
https://github.com/bamlab/react-native-image-resizer提供了调整本Map像大小的API。
它允许您指定:
API
tgabmvqs3#
您可以使用expo-image-manipulator:
wydwbb8l4#
我的自定义解决方案的图像压缩在React原生的基础上图像大小。