Camera Interchange

I developed an application using Phone Gap version 0.9.3 ...

When I open the camera in my application, it always opens in landscape mode and, when captured, the image returns in landscape format ...

How to change camera mode 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 the manifest, I mentioned:

 <activity android:name="com.android.camera.Camera" android:screenOrientation="portrait"> </activity> 

Please help me with this ...

+8
android cordova
source share
4 answers

the orientation of the photo is not saved when the image is returned in base64 format (all EXIF ​​data is deleted).

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

+7
source share

Try the following: correctOrientation: true

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

The "correctOrientation" parameter works fine for me - but only if you also use the "targetWidth" and "targetHeight" parameters (for example, set them to "800"). It seems that some devices may not have enough memory to rotate the full resolution image.

Update: Here is a good 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

+6
source share

I solved my problem instead of saving as url file. The file will be placed in a temporary folder along with the correct EXIF ​​data. There may be some devices where you must manually delete files when closing the application.

When referencing a url file instead of data, img seems to display correctly.

0
source share

All Articles