'react-native-image-picker getting reverse height and width
I am using react-native-image-picker library to capture image code as follow:
launchImageLibrary({
includeExtra: false,
mediaType: "photo",
selectionLimit: 0,
quality: 1,
maxWidth: 1000,
maxHeight: 1500
}, (res)=>{
console.log(res);
});
When I am taking capture using android real device(portrait) getting image with following:
{
uri: "string",
height: 1000,
width: 750
}
Expected and correct response:
{
uri: "string",
height: 750,
width: 1000
}
can someone help me out?
Solution 1:[1]
I advice you to use react-native-image-crop-picker library.
The code below works for me. You can use it without cropping if you do not need it.
import ImagePicker from 'react-native-image-crop-picker';
ImagePicker.openCamera({
width: 768,
height: 1024,
cropping: false,
}).then(image => {
console.log(image)
})
Looks like we have same aspect ratio 3/4. So I guess it may help you.
Solution 2:[2]
On android, i have the same problem on cropping the photo. The width are inverted by the height on the new photo cropped.
I fix the problem by removing the original width and height. (But for Ios, the original width and height are important)
import ImagePicker from 'react-native-image-crop-picker' try {
ImagePicker.openCropper({
path: uri,
// width:2048,
// height: 4096,
includeExif: true,
hideBottomControls: true,
waitAnimationEnd: false,
cropperChooseText: 'ok',
cropperCancelText: 'Cancel',
}).then(async image => {
callback(image.path)
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ahmet Firat Keler |
Solution 2 |