react-native - 与 Expo 配合使用的 React Native 图像裁剪工具
问题描述
有谁知道在 Expo 设置中工作的 React Native 的图像裁剪工具。非常流行的react-native-image-crop-picker没有。有其他选择吗?我似乎找不到任何东西。
解决方案
您可以使用下载图像,Expo#FileSystem
然后使用Expo#ImageManipulator
以下示例裁剪缓存的图像
/*
* @param link {string} URI of the image on the server
* @param name {string} Name of the image with extension
*/
_downloadAndCrop = (link, name, cropSize = { width: 200, height: 200 }) => {
FileSystem.downloadAsync(
link,
name
)
.then(({ uri }) => {
console.log('Finished downloading to ', uri);
//Your new cropped image
const cropImage = ImageManipulator.manipulate(uri, [
crop: {
originX: 0,
originY: 0,
width: cropSize.width,
height: cropSize.height
}
}], {});
})
.catch(error => {
console.error(error);
});
}
推荐阅读
- mips - MIPS - 逐字符打印整数
- php - php Session PHP 获取与用户相关的数据
- r - 求解 ODE 的非自治系统
- sql - SQL Server 错误:INSERT 语句与 FOREIGN KEY 约束冲突
- php - 将 php 数组特定字段写入磁盘
- javascript - 不需要在javascript的参数中声明类型?
- sql - 检测递归 CTE 中的重复项
- java - 如何通过火花流(或 kafka)从 postgresql(或 mysql)读取实时更新数据?
- c# - 调试时 Visual Studio 2017 无法检查 Razor 页面视图上的变量值
- apache-spark - 在这种情况下,火花缓存()是否会导致驱动程序收集()?