use of android.media.ExifInterface in project SmartAndroidSource by jaychou2012.
the class BaseImageDecoder method defineExifOrientation.
protected ExifInfo defineExifOrientation(String imageUri) {
int rotation = 0;
boolean flip = false;
try {
ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri));
int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch(exifOrientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
flip = true;
case ExifInterface.ORIENTATION_NORMAL:
rotation = 0;
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
flip = true;
case ExifInterface.ORIENTATION_ROTATE_90:
rotation = 90;
break;
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
flip = true;
case ExifInterface.ORIENTATION_ROTATE_180:
rotation = 180;
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
flip = true;
case ExifInterface.ORIENTATION_ROTATE_270:
rotation = 270;
break;
}
} catch (IOException e) {
L.w("Can't read EXIF tags from file [%s]", imageUri);
}
return new ExifInfo(rotation, flip);
}
use of android.media.ExifInterface in project Android-skin-support by ximsfei.
the class ImageUtils method getImageRotateAngle.
public static int getImageRotateAngle(String filePath) {
ExifInterface exif;
try {
exif = new ExifInterface(filePath);
} catch (IOException e) {
e.printStackTrace();
exif = null;
}
int angle = 0;
if (exif != null) {
int ori = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
switch(ori) {
case ExifInterface.ORIENTATION_ROTATE_90:
angle = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
angle = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
angle = 270;
break;
default:
angle = 0;
break;
}
}
return angle;
}
use of android.media.ExifInterface in project mobile-android by photo.
the class ImageUtils method getExifDateTime.
/**
* Returns number of milliseconds since Jan. 1, 1970, midnight. Returns -1
* if the date time information if not available.
*
* @param attributeName
* @throws IOException
*/
public static long getExifDateTime(String fileName) throws IOException {
ExifInterface exif = new ExifInterface(fileName);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
long result = getExifDateTime(exif, TAG_DATETIME_ORIGINAL, formatter);
CommonUtils.debug(TAG, "getExifDateTime: getting %1$s", TAG_DATETIME_ORIGINAL);
if (result == -1) {
CommonUtils.debug(TAG, "getExifDateTime: getting %1$s", TAG_DATETIME_DIGITIZED);
result = getExifDateTime(exif, TAG_DATETIME_DIGITIZED, formatter);
}
if (result == -1) {
CommonUtils.debug(TAG, "getExifDateTime: getting %1$s", TAG_DATETIME);
result = getExifDateTime(exif, TAG_DATETIME, formatter);
}
return result;
}
use of android.media.ExifInterface in project TakePhoto by crazycodeboy.
the class ImageRotateUtil method getBitmapDegree.
/**
* 读取图片的旋转的角度
*
* @param path 图片绝对路径
* @return 图片的旋转角度
*/
private int getBitmapDegree(String path) {
int degree = 0;
try {
// 从指定路径下读取图片,并获取其EXIF信息
ExifInterface exifInterface = new ExifInterface(path);
// 获取图片的旋转信息
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return degree;
}
use of android.media.ExifInterface in project PhotoNoter by yydcdut.
the class SandBoxServicePresenterImpl method setExif.
// todo isMirror不好做啊!
private void setExif(PhotoNote photoNote, SandExif sandExif, String cameraId, boolean isMirror) throws IOException {
ExifInterface exif = new ExifInterface(photoNote.getBigPhotoPathWithoutFile());
if (cameraId.equals(Const.CAMERA_BACK)) {
exif.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_ROTATE_90));
} else {
exif.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_ROTATE_270));
}
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, sandExif.getLatitude());
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, sandExif.getLongitude());
exif.setAttribute(ExifInterface.TAG_WHITE_BALANCE, String.valueOf(sandExif.getWhiteBalance()));
exif.setAttribute(ExifInterface.TAG_FLASH, String.valueOf(sandExif.getFlash()));
exif.setAttribute(ExifInterface.TAG_IMAGE_LENGTH, String.valueOf(sandExif.getImageLength()));
exif.setAttribute(ExifInterface.TAG_IMAGE_WIDTH, String.valueOf(sandExif.getImageWidth()));
exif.setAttribute(ExifInterface.TAG_MAKE, sandExif.getMake());
exif.setAttribute(ExifInterface.TAG_MODEL, sandExif.getModel());
exif.saveAttributes();
ExifInterface exif2 = new ExifInterface(photoNote.getSmallPhotoPathWithoutFile());
if (cameraId.equals(Const.CAMERA_BACK)) {
exif2.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_ROTATE_90));
} else {
exif2.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_ROTATE_270));
}
exif2.saveAttributes();
}
Aggregations