为了实现这一点,您可以使用react原生图像裁剪选择器库来选择多个图像,然后循环浏览所选图像以单独裁剪每个图像
try {
const selectedImages = await ImagePicker.openPicker({
multiple: true,
mediaType: 'photo',
});
// Loop through selected images and crop each one
selectedImages.forEach(async (image) => {
try {
const croppedImage = await ImagePicker.openCropper({
path: image.path,
width: 300,
height: 300,
});
console.log('Cropped image:', croppedImage);
// Do something with the cropped image, like uploading it to a server
} catch (cropError) {
console.error('Error cropping image:', cropError);
}
});
} catch (pickerError) {
console.error('Error selecting images:', pickerError);
}