通过相机拍摄的照片太大,无法在React native中有效地上传和下载。
是否有API或库在React Native中压缩PNG图像文件?
https://github.com/bamlab/react-native-image-resizer提供了用于调整本地图像大小的API。
它允许您指定:
原料药
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.
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句