Incorrect orientation of image from Android

9 posts, 0 answers
  1. Arnaud
    Arnaud avatar
    18 posts
    Member since:
    Mar 2016

    Posted 02 Oct Link to this post

    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

  2. Martin
    Admin
    Martin avatar
    67 posts

    Posted 04 Oct Link to this post

    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.
     
  3. Arnaud
    Arnaud avatar
    18 posts
    Member since:
    Mar 2016

    Posted 05 Oct in reply to Martin Link to this post

    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

     

  4. Arnaud
    Arnaud avatar
    18 posts
    Member since:
    Mar 2016

    Posted 05 Oct in reply to Arnaud Link to this post

    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!

  5. Arnaud
    Arnaud avatar
    18 posts
    Member since:
    Mar 2016

    Posted 05 Oct in reply to Arnaud Link to this post

    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!

  6. Martin
    Admin
    Martin avatar
    67 posts

    Posted 07 Oct Link to this post

    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.
     
  7. Arnaud
    Arnaud avatar
    18 posts
    Member since:
    Mar 2016

    Posted 07 Oct in reply to Martin Link to this post

    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

  8. Arnaud
    Arnaud avatar
    18 posts
    Member since:
    Mar 2016

    Posted 11 Oct Link to this post

    Hello,

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

    Thank you!

    Arnaud

  9. Martin
    Admin
    Martin avatar
    67 posts

    Posted 11 Oct Link to this post

    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.
     
Back to Top