У меня есть пример:
onImageUpload = async () => {
try {
if (cameraRollPerm === 'granted') {
let pickerResult = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [4, 3],
});
var wantedMaxSize = 150;
var rawheight = pickerResult.height;
var rawwidth = pickerResult.width;
var ratio = rawwidth / rawheight;
var wantedwidth = wantedMaxSize;
var wantedheight = wantedMaxSize/ratio;
// check vertical or horizontal
if(rawheight > rawwidth){
wantedwidth = wantedMaxSize*ratio;
wantedheight = wantedMaxSize;
}
let resizedUri = await new Promise((resolve, reject) => {
ImageEditor.cropImage(pickerResult.uri,
{
offset: { x: 0, y: 0 },
size: { width: pickerResult.width, height: pickerResult.height },
displaySize: { width: wantedwidth, height: wantedheight },
resizeMode: 'contain',
},
(uri) => resolve(uri),
() => reject(),
);
});
let uploadUrl = await firebaseSvc.uploadImage(resizedUri);
console.log(uploadUrl)
}
} catch (err) {
console.log('onImageUpload error:' + err.message);
}
};
с firebaseSvc = firebase initializeApp ({...})