use of android.media.ExifInterface in project GalleryFinal by pengjianbo.
the class CropUtil method copyExifRotation.
public static boolean copyExifRotation(File sourceFile, File destFile) {
if (sourceFile == null || destFile == null)
return false;
try {
ExifInterface exifSource = new ExifInterface(sourceFile.getAbsolutePath());
ExifInterface exifDest = new ExifInterface(destFile.getAbsolutePath());
exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, exifSource.getAttribute(ExifInterface.TAG_ORIENTATION));
exifDest.saveAttributes();
return true;
} catch (IOException e) {
ILogger.e(e);
return false;
}
}
use of android.media.ExifInterface in project android_packages_apps_Camera by CyanogenMod.
the class PanoramaModule method savePanorama.
private Uri savePanorama(byte[] jpegData, int width, int height, int orientation) {
if (jpegData != null) {
String filename = PanoUtil.createName(mActivity.getResources().getString(R.string.pano_file_name_format), mTimeTaken);
String filepath = Storage.getStorage().writeFile(filename, jpegData);
// Add Exif tags.
try {
ExifInterface exif = new ExifInterface(filepath);
exif.setAttribute(ExifInterface.TAG_GPS_DATESTAMP, mGPSDateStampFormat.format(mTimeTaken));
exif.setAttribute(ExifInterface.TAG_GPS_TIMESTAMP, mGPSTimeStampFormat.format(mTimeTaken));
exif.setAttribute(ExifInterface.TAG_DATETIME, mDateTimeStampFormat.format(mTimeTaken));
exif.setAttribute(ExifInterface.TAG_ORIENTATION, getExifOrientation(orientation));
exif.saveAttributes();
} catch (IOException e) {
Log.e(TAG, "Cannot set EXIF for " + filepath, e);
}
int jpegLength = (int) (new File(filepath).length());
return Storage.getStorage().addImage(mContentResolver, filename, mTimeTaken, null, orientation, jpegLength, filepath, width, height);
}
return null;
}
use of android.media.ExifInterface in project smartmodule by carozhu.
the class Bitmaputil method readPictureDegree.
/**
* 读取图片属性:旋转的角度
*
* @param path 图片绝对路径
* @return degree旋转的角度
*/
public static int readPictureDegree(String path) {
int degree = 0;
try {
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 JustAndroid by chinaltz.
the class LubanCompresser method getImageSpinAngle.
/**
* obtain the image rotation angle
*
* @param path path of target image
*/
private int getImageSpinAngle(String path) throws IOException {
int degree = 0;
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;
}
return degree;
}
use of android.media.ExifInterface in project JustAndroid by chinaltz.
the class PictureFileUtils method readPictureDegree.
/**
* 读取图片属性:旋转的角度
*
* @param path 图片绝对路径
* @return degree旋转的角度
*/
public static int readPictureDegree(String path) {
int degree = 0;
try {
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;
}
Aggregations