首页 文章

与世博会合作的React Native图像裁剪工具

提问于
浏览
0

是否有人知道React Native的图像裁剪工具在Expo设置中有效 . 非常受欢迎的react-native-image-crop-picker似乎找不到任何东西 .

2 回答

  • 0

    您可以使用 Expo#FileSystem 下载图像,然后使用_466899裁剪缓存的图像 . 这是一个示例

    /*
     * @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);
       });
    }
    
  • 0

    您可以使用方面4:3,16:9,1:1等

    import { ImagePicker } from 'expo';
    

    你从画廊得到照片吗?

    const photo = await ImagePicker.launchImageLibraryAsync({
       allowsEditing: true,
       aspect: [4, 3],
    });
    

相关问题