Home » Android » android – Phone Gap camera orientation

android – Phone Gap camera orientation

Posted by: admin June 15, 2020 Leave a comment


I have developed an app using Phone Gap version 0.9.3

When I open camera in my app ,it always opens in landscape mode and, on capture, the image is returned in landscape format…

How can I change the mode of camera to portrait

navigator.camera.getPicture(onsuccess, fail, {quality: 45,destinationType : Camera.DestinationType.DATA_URL, sourceType: src},img_id);

function onsuccess(imageData) {
    $('#'+imgID).attr('src', 'data:image/jpeg;base64,' + imageData);
    $("#"+imgID+"_IMG").attr('src', 'data:image/jpeg;base64,' + imageData);

In manifest i had mention:

<activity android:name="com.android.camera.Camera"

Please help me in this…

How to&Answers:

photo orientation is not stored when returning an image in base64 format (all EXIF data is stripped).

You should use the accelerometer or screen orientation to “know” if the image was taken in portrait or landscape and then display it accordingly.


Try this : correctOrientation: true

function getPhoto(source) {

    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 30, 
    destinationType: destinationType.FILE_URI,
    sourceType: source,
    correctOrientation: true });



The “correctOrientation” parameter works fine for me – but only if you’re also using the “targetWidth” and “targetHeight” parameters (e.g. set them to “800”). It seems that some devices may not have enough memory to rotate a full resolution picture.

Here’s a nice article with useful information about memory, scaling and EXIF issues with the Phonegap Camera code:


I’ve solved my problem my saving as file url instead. The file will be placed in a temporally folder along with correct EXIF data. There might be some devices where you have to manually delete the files when closing the application though.

When referencing the file url instead of the data, the img seem to get displayed correctly.