Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phone Gap camera orientation

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) {
    localStorage.setItem("image_captured","Yes");
    $('#'+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"
    android:screenOrientation="portrait">
</activity>

Please help me in this...

like image 641
Sandeep P Avatar asked Mar 28 '12 07:03

Sandeep P


3 Answers

Try this : correctOrientation: true

function getPhoto(source) {

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

}
like image 140
Akhilesh Kumar Avatar answered Nov 08 '22 19:11

Akhilesh Kumar


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.

like image 7
BigBalli Avatar answered Nov 08 '22 17:11

BigBalli


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.

Update: Here's a nice article with useful information about memory, scaling and EXIF issues with the Phonegap Camera code: http://simonmacdonald.blogspot.ca/2012/07/change-to-camera-code-in-phonegap-190.html

like image 6
Philipp Rieber Avatar answered Nov 08 '22 19:11

Philipp Rieber