The current orientation of the telephone table during image capture

I can find information in my Accelerometer docs to return device orientation. Is there anyway telephone service can return the way the device was held during shooting? To use the camera, I do the following:

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 he returns successfully, he 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 success callback that returns the way the device was held during shooting, so I can send it to a file for upload and rotate the image correctly?

+6
source share
1 answer

To make your life easier, you can simply call:

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

then you will get a file that will be rotated correctly.

+23
source

Source: https://habr.com/ru/post/926802/


All Articles