反应原生相机胶卷 .heic 文件

Tho*_*rth 5 camera-roll reactjs react-native ios11

IOS 11 上的新 .HEIC 文件导致问题,因为图像托管服务不支持它。

相机胶卷 api 正在返回 .HEIC 文件。我们如何才能获得 .JPG/.PNG 文件。或将 .HEIC 转换为 .JPG/.PNG

小智 0

ImagePicker.showImagePicker(options, imgResponse => {

this.setState({ imageLoading: true, avatarMediaId: null });

if ((imgResponse.didCancel) || (imgResponse.error)) {
    this.setState({ imageLoading: false });
} else {
    let source = {};
    let fileName = imgResponse.fileName;
    if (Platform.OS === 'ios' && (fileName.endsWith('.heic') || fileName.endsWith('.HEIC'))) {
        fileName = `${fileName.split(".")[0]}.JPG`;
    }
    source = { uri: imgResponse.uri, fileName };
    this.uploadImage(source);
}});
Run Code Online (Sandbox Code Playgroud)