Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap return current orientation during image capture

I can only find information in their docs about the Accelerometer for returning device orientation. Is there anyway phonegap can return what way the device was being held when a picture was taken? To use the camera, I do this:

function capturePhoto() {
    // Take picture using device camera and retrieve image as base64-encoded string
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
        destinationType: destinationType.DATA_URL });
}

When it returns successful, it does this.

 function onPhotoDataSuccess(imageData) {
        var baseImg = imageData;
        $('#uploadPreUpImgSwapHtml').html('<img src="data:image/jpeg;base64,'+ baseImg +'" style="max-width:100%; width:auto; max-height:300px; height:auto;" / >');
        $('#uploadPreBaseDataSwapHtml').html('<input type="hidden" id="chosenPictureData" value="'+ baseImg +'" />');
        $('#uploadPictureBtnHideHtml').fadeIn();

    }

Is there a callback to the success that returns what way the device was being held while the picture was taken so I can send it to my upload file and rotate the picture correctly?

like image 516
user1053263 Avatar asked Oct 03 '12 02:10

user1053263


1 Answers

To make your life easier you can just call:

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
    destinationType: destinationType.FILE_URI, 
    correctOrientation: true });

then you'll get a file that is rotated properly.

like image 86
Simon MacDonald Avatar answered Oct 19 '22 23:10

Simon MacDonald