This is a migrated thread and some comments may be shown as answers.

Incorrect orientation of image from Android

8 Answers 542 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arnaud
Top achievements
Rank 1
Arnaud asked on 02 Oct 2016, 07:08 PM

Hello,

I'm developing an app based on image capture from the device camera. I'm using the cordova camera plugin and everything was working fine until a recent update of the plugin.

It seems that when capturing an image from an android device, the image is always taken in landscape and contain information in the EXIF metadata if the image was captured in portrait mode.

The cordova camera plugin is correcting the orientation (through the correctionOrientation:true option) and the image is displayed correctly after capture (the html img tag does not consider EXIF metadata I guess). However, when uploaded on the backend server the image appears rotated of 90° clockwise. This ends up creating a rotated image on other devices after downloading the file from the server.

I believe that the camera plugin is not updating the EXIF metadata of the file anymore which results in correcting twice the orientation of the image (once on the frontend and once in the backend). Am I right to believe that the backend is interpreting the EXIF metadata contained in jpeg file when creating the file?

I guess that the best solution would be to modify the camera plugin or to raise the error to the development team, but any update would take month to be integrated. Can you propose me any other solution to have a correct behaviour for image orientation? or lead me to any other direction if I'm completely mistaken why the orientation of the images are incorrect?

Thank you very much for your help

Best

Arnaud

8 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 04 Oct 2016, 03:34 PM

Hi Arnaud,

I have tried to reproduce the issue in a project using cordova-plugin-camera v.2.3 with Cordova 5.0 and uploading the image to the backend in BASE64 format - all was working fine.

Could you please send a working sample on how you capture the file and upload the file to the backend service in order to reproduce the issue.

Looking forward for your reply.

Regards,
Martin
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Arnaud
Top achievements
Rank 1
answered on 05 Oct 2016, 09:45 AM

Hello

I'm also using the camera plugin in version 2.3 (I tried version 2.3.1-dev with the same result)

cordova-plugin-camera 2.3.0 "Camera"

But I'm not uploading the file in BASE64 format. I did not use the BASE64 format before but everything was working fine until recently..

The parameters of the acquisition for Android are as follows:

destinationType: Camera.DestinationType.FILE_URI,
quality: 50,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 1500,
targetHeight: 1500,
correctOrientation: true,
saveToPhotoAlbum: false

while the parameters for the upload are (rename is an optional parameter in my code):

var options = {
    fileName: reName ? reName : fileName,
    mimeType: 'image/jpeg',
    headers: provider.buildAuthHeader()
};

 

I'm going to try the BASE64 format and let you if I observe the same behaviour. Although that requires a bit of refactor of my code. I also need to be able to store image on the device in case it is offline and can not send the picture directly. I'm not sur how to do it right now with BASE64 encoded string.

The best would be that everything works with the current options as it used to be :)

Thank you very much for your help.

Best

Arnaud

 

0
Arnaud
Top achievements
Rank 1
answered on 05 Oct 2016, 09:57 AM

Apparently, using BASE64 format is also not recommended by the development team of the camera plugin:

"DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible"

Just tested it anyway. Indeed the file created on the server is in the correct orientation. This let me further believe that the problem is somewhere in the interpretation of the jpeg metadata when using FILE_URI rather than DATA_URL.

Thank you!

0
Arnaud
Top achievements
Rank 1
answered on 05 Oct 2016, 09:57 AM

Apparently, using BASE64 format is also not recommended by the development team of the camera plugin:

"DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible"

Just tested it anyway. Indeed the file created on the server is in the correct orientation. This let me further believe that the problem is somewhere in the interpretation of the jpeg metadata when using FILE_URI rather than DATA_URL.

Thank you!

0
Martin
Telerik team
answered on 07 Oct 2016, 10:05 AM
Hi Arnaud,

I have tested again on Nexus 5 device with your settings and it is all working as expected. On what device are you testing?

I also found this thread and this issue in the plugin backlog with a similar problem. Please take a look at it and see if this can solve the problem.

Let me know if this has helped.

Regards,
Martin
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Arnaud
Top achievements
Rank 1
answered on 07 Oct 2016, 10:25 AM

Hello,

Damned, sorry to hear that. What is really strange is that it used to worked perfectly well until suddenly, something happened!

I tested it on 2 different samsung devices (S5 and S5 mini). Other users are reporting this on samsung devices while working correctly on Nexus 5...

I really don't know what I'm supposed to do to correct this issue (no real solutions provided in your link unfortunately)

Thank you

0
Arnaud
Top achievements
Rank 1
answered on 11 Oct 2016, 08:33 AM

Hello,

Any update or idea that I can test to solve this issue?

Thank you!

Arnaud

0
Martin
Telerik team
answered on 11 Oct 2016, 10:14 AM
Hi Arnaud,

You could try using the previous version of the camera plugin (to change the version you would follow these steps) if it was working correctly as you mentioned in your first post.

You could also test to see if the problem is indeed in the "OutOfMemoryError" as stated in the provided thread, which sets the "correctOrientation" option to false by reducing the target size and see if this fixes the issue.

I hope this would help.

Regards,
Martin
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
General Discussion
Asked by
Arnaud
Top achievements
Rank 1
Answers by
Martin
Telerik team
Arnaud
Top achievements
Rank 1
Share this question
or