本项目是一个图片选择器,支持照相机,视频压缩,多图像裁剪,支持iOS和Android
效果预览
使用方法
import 库
import ImagePicker from 'react-native-image-crop-picker';
从画廊选择
调用能够截取的单图像选择器
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: true
}).then(image => {
console.log(image);
});
调用多图像选择器
ImagePicker.openPicker({
multiple: true
}).then(images => {
console.log(images);
});
从照相机选择
ImagePicker.openCamera({
width: 300,
height: 400,
cropping: true
}).then(image => {
console.log(image);
});
可选的清理
模块创建的tmp图像将会在未来的某个时刻自动被清理。如果你想强迫清理,你可以使用 clean ?去清理所有的tmp文件,或者使用 cleanSingle(path) ?去清理单tmp文件。
ImagePicker.clean().then(() => {
console.log('removed all tmp images from tmp directory');
}).catch(e => {
alert(e);
});