简体   繁体   中英

How to crop image before uploading the profile picture in react native?

我需要裁剪选定的图像或从相机中拍摄的照片,然后将其上传到后端。

You can install sharp and then:

sharp(originalImage).extract({ width: 1920, height: 1080, left: 60, top: 40 }).toFile("outputImage")
    .then(function(new_file_info) {
        console.log("Image cropped and saved");
    })
    .catch(function(err) {
        console.log("An error occured");
    });

react-native-image-crop-picker is the library you should use

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM