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());

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值