managed to set setAttribute(ExifInterface.TAG_ORIENTATION, ..) but not sure how can I see the change?

StackOverflow https://stackoverflow.com/questions/23684730

문제

My android

My app takes a photo in portrait.

In the gallery I see it OK

but when saved to my server i see it in landscape.

(This happens only on Samsun S2)

I have read it might be connected with exif tags.

I have checked my image file and got

ORIENTATION_ROTATE_90

what does this mean?

I have tried to set it to ORIENTATION_NORAML or ORIENTATION_UNDEFINED but I'm not sure how to see the change?

In the photo gallery i see it in landscape only (whether taken in portrait or landscape)

I managed to set the attributes as I read the new ones correctly.

but how do I see the change? does this should help my original problem?

      ExifInterface exif;
        try {
          exif = new ExifInterface(imageFilename);
          int orientation =
              exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
          exif.setAttribute(ExifInterface.TAG_ORIENTATION,
              String.valueOf(ExifInterface.ORIENTATION_ROTATE_270));
//also tried ExifInterface.ORIENTATION_ROTATE_UNDEFINED)
          exif.saveAttributes();
          orientation =
              exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
          boolean b = orientation == Configuration.ORIENTATION_LANDSCAPE;

        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

how can I fix this?

why is changing the exif tag not enough? and if changing the exif tag does nothing - why do I need to change it in addition to rotation?

도움이 되었습니까?

해결책

My app takes a photo in portrait. In the gallery I see it OK but when saved to my server i see it in landscape.

That is because your server is ignoring the EXIF header.

(This happens only on Samsun S2)

It happens on many more devices than this. It's one of the many things that I patch up for developers in my CWAC-Camera library.

I have checked my image file and got ORIENTATION_ROTATE_90 what does this mean?

It is a message from the camera, to image-viewing apps, saying "plz rotate this 90 degrees when you show it! kthxbye"

I have tried to set it to ORIENTATION_NORAML or ORIENTATION_UNDEFINED but I'm not sure how to see the change?

All that will do is cause your image to be wrong everywhere, if you did nothing else. You need to rotate the image file in addition to dealing with the EXIF tag.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top