ImageFileUtil.java 646 B

12345678910111213141516171819202122232425
  1. package epson.print.Util;
  2. import android.media.ExifInterface;
  3. import java.io.IOException;
  4. public class ImageFileUtil {
  5. public static int getExifRotationDegree(String str) {
  6. try {
  7. int attributeInt = new ExifInterface(str).getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, 0);
  8. if (attributeInt == 3) {
  9. return 2;
  10. }
  11. if (attributeInt == 6) {
  12. return 1;
  13. }
  14. if (attributeInt != 8) {
  15. return 0;
  16. }
  17. return 3;
  18. } catch (IOException unused) {
  19. return -1;
  20. }
  21. }
  22. }