Back to project page encrypted-camera.
The source code is released under:
Apache License
If you think the Android project encrypted-camera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.andrewreitz.encryptedcamera.image; /*from w w w .j av a2 s. com*/ import android.media.ExifInterface; import java.io.File; import java.io.IOException; import static android.media.ExifInterface.ORIENTATION_NORMAL; import static android.media.ExifInterface.TAG_ORIENTATION; public final class ImageRotation { private ImageRotation() { // No Instances } /** * Checks if an image needs to be rotated. If there was an error 0 will be returned * * @param image image to check if rotation is needed * @return rotation value if one, otherwise 0 * @throws IOException if the image can't be read (Like it's not an image) */ public static int getRotation(File image) throws IOException { int rotation = 0; ExifInterface exif = new ExifInterface(image.getAbsolutePath()); int orientation = exif.getAttributeInt(TAG_ORIENTATION, ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotation = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: rotation = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotation = 90; break; } return rotation; } }