I am using cordova camera plugin latest to take a photo of documents in my cordova android app. The following are the options:
camera.options = {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
cameraDirection: 0,
correctOrientation:false,
targetWidth:2048,
targetHeight:2048,
saveToPhotoAlbum: false
};
But when I click a photo of my document in portrait mode, the camera flips it 90 degrees and it becomes landscape. I don't want it to flip it. I want it to keep it as it is. Also, I must point out it only happens when my phone is parallel to the ground, when I am clicking a photo of a document placed on the table.
I could not find anything helpful related to this in the camera plugin repo. Can somebody help me?
I just wanna share on how I solved my issue, on why the cordova camera forces the portrait shot to landscape when rendered on HTML.
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL, //DATA_URL , FILE_URI
sourceType: Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPG,
mediaType: Camera.MediaType.PICTURE,
targetWidth: 500,
targetHeight: 500,
saveToPhotoAlbum: true,
correctOrientation: true //Corrects Android orientation quirks
}
The property correctOrientation actually did not completely solved the issue. Instead I change the encodingType to from PNG to JPG.
This question is a bit old but in my case setting correctOrientation: true
in the camera options has worked. I have used cordova-plugin-camera.
const cameraOptions = {
cameraDirection: 1,
correctOrientation: true,
destinationType: 1
}
navigator.camera.getPicture(
function(path) {
// preview the image in the dom
// you need to have an <img id="img"> in your dom
document.querySelector("#img").src = path;
},
function(err) {
console.warn('an error has occured: ' + err);
}, cameraOptions
)
Please try to remove:
correctOrientation:false
from options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With