Android EXIF data always 0, how to change it?

后端 未结 5 2175
[愿得一人]
[愿得一人] 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:18

    There is one class to read and update these information of images.

    To update the attributes you can use like this

    ExifInterface ef = new ExifInterface(filePath);
                ef.setAttribute(MAKE_TAG, MAKE_TAG);
                ef.setAttribute(ExifInterface.TAG_ORIENTATION, orientation+"");
                ef.saveAttributes();
    

    and for reading you can use like this

     ExifInterface exif = null;
            try {
                exif = new ExifInterface(absolutePath+path);
            } catch (IOException e) {
                e.printStackTrace();
            }
            int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                    ExifInterface.ORIENTATION_UNDEFINED);
    

    I hope it will help you

提交回复
热议问题