600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > getAttribute实例例java_Java ExifInterface.getAttribute方法代码示例

getAttribute实例例java_Java ExifInterface.getAttribute方法代码示例

时间:2019-11-13 22:54:37

相关推荐

getAttribute实例例java_Java ExifInterface.getAttribute方法代码示例

import android.media.ExifInterface; //导入方法依赖的package包/类

public static void copyExif(ExifInterface originalExif, int width, int height, String imageOutputPath) {

String[] attributes = new String[]{

ExifInterface.TAG_APERTURE,

ExifInterface.TAG_DATETIME,

ExifInterface.TAG_DATETIME_DIGITIZED,

ExifInterface.TAG_EXPOSURE_TIME,

ExifInterface.TAG_FLASH,

ExifInterface.TAG_FOCAL_LENGTH,

ExifInterface.TAG_GPS_ALTITUDE,

ExifInterface.TAG_GPS_ALTITUDE_REF,

ExifInterface.TAG_GPS_DATESTAMP,

ExifInterface.TAG_GPS_LATITUDE,

ExifInterface.TAG_GPS_LATITUDE_REF,

ExifInterface.TAG_GPS_LONGITUDE,

ExifInterface.TAG_GPS_LONGITUDE_REF,

ExifInterface.TAG_GPS_PROCESSING_METHOD,

ExifInterface.TAG_GPS_TIMESTAMP,

ExifInterface.TAG_ISO,

ExifInterface.TAG_MAKE,

ExifInterface.TAG_MODEL,

ExifInterface.TAG_SUBSEC_TIME,

ExifInterface.TAG_SUBSEC_TIME_DIG,

ExifInterface.TAG_SUBSEC_TIME_ORIG,

ExifInterface.TAG_WHITE_BALANCE

};

try {

ExifInterface newExif = new ExifInterface(imageOutputPath);

String value;

for (String attribute : attributes) {

value = originalExif.getAttribute(attribute);

if (!TextUtils.isEmpty(value)) {

newExif.setAttribute(attribute, value);

}

}

newExif.setAttribute(ExifInterface.TAG_IMAGE_WIDTH, String.valueOf(width));

newExif.setAttribute(ExifInterface.TAG_IMAGE_LENGTH, String.valueOf(height));

newExif.setAttribute(ExifInterface.TAG_ORIENTATION, "0");

newExif.saveAttributes();

} catch (IOException e) {

Log.d(TAG, e.getMessage());

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。