Android EXIF data always 0, how to change it?

后端 未结 5 2176
[愿得一人]
[愿得一人] 2021-02-12 03:38

I have an app that captures photos using the native Camera and then uploads them to a server. My problem is that all the photos have an EXIF orientation value of 0,

5条回答
  •  日久生厌
    2021-02-12 04:17

    Turns out my code was able to set the EXIF data, but there is a discrepancy between how Android interprets this data and how iOS and Chrome on a Mac (where I was checking the resulting file) interprets it.

    This is the only code needed to set EXIF orientation:

    ExifInterface exif = new ExifInterface(pictureFile.toString());
    exif.setAttribute(ExifInterface.TAG_ORIENTATION, "3");
    exif.saveAttributes();
    

    However, setting 3 shows up as 0 on iOS and the image is sideways in Chrome.

    setting 6 shows up as 3 on iOS and the image looks right in Chrome.

提交回复
热议问题