在自定义相机拍照时用到了 ExifInterface,决定将一些常用的属性记录下来。
下面是属性解释和实际照片的属性值,其中经纬度由于没有值为了方便解释从其他地方copy的值。
测试机为小米6,Android9,MIUI 11.0.5 稳定版。
注意,同一个对象流只能被 ExifInferface 使用一次,如:
val byteArrayInputStream = ByteArrayInputStream(byteArray)
log(ExifInterface(byteArrayInputStream))
// 这 ExifInterface 对象的值都是空的
log(ExifInterface(byteArrayInputStream))
private fun log(exifInterface: ExifInterface) {
//图片方向,6表示旋转90° ## orientation=6
val orientation = exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION)
// 图片修改时间,以"YYYY:MM:DD HH:MM:SS"格式显示 24 小时制。## dateTime=2020:05:23 08:13:17
val dateTime = exifInterface.getAttribute(ExifInterface.TAG_DATETIME)
// 设备制造商 ## make=Xiaomi
val make = exifInterface.getAttribute(ExifInterface.TAG_MAKE)
// 设备型号 ## model=MI 6
val model = exifInterface.getAttribute(ExifInterface.TAG_MODEL)
// 闪光灯模式,奇数值表示使用了闪光灯 ## flash=24
val flash = exifInterface.getAttribute(ExifInterface.TAG_FLASH)
// 图片高度上的分辨率, 这个宽高是图片方向为0°时的值,为90°时宽高应该对掉 ## imageLength=1080
val imageLength = exifInterface.getAttribute(ExifInterface.TAG_IMAGE_LENGTH)
// 图片宽度上的分辨率 ## imageWidth=1440
val imageWidth = exifInterface.getAttribute(ExifInterface.TAG_IMAGE_WIDTH)
// 纬度 格式为 度,分,秒 ## latitude=34/1,0/1,536875/10000
val latitude = exifInterface.getAttribute(ExifInterface.TAG_GPS_LATITUDE)
// 经度 格式为 度,分,秒 ## longitude=109/1,0/1,97687/10000
val longitude = exifInterface.getAttribute(ExifInterface.TAG_GPS_LONGITUDE)
// 指示纬度是北纬还是南纬 ## latitudeRef=N
val latitudeRef = exifInterface.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF)
// 指示经度是东经还是西经。 ## longitudeRef=E
val longitudeRef = exifInterface.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF)
// 海拔高度,米 ## altitude=816000/1000
val altitude = exifInterface.getAttribute(ExifInterface.TAG_GPS_ALTITUDE)
// 0表示海平面以上,1表示一下 ## altitudeRef=0
val altitudeRef = exifInterface.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF)
// 曝光时间,单位s ## exposureTime=0.016666666666666666
val exposureTime = exifInterface.getAttribute(ExifInterface.TAG_EXPOSURE_TIME)
// 镜头光圈,单位是APEX值。 ## aperture=169/100
val aperture = exifInterface.getAttribute(ExifInterface.TAG_APERTURE_VALUE)
// ISO 值 ## isoSpeedRatings=200
val isoSpeedRatings = exifInterface.getAttribute(ExifInterface.TAG_PHOTOGRAPHIC_SENSITIVITY)
// 不知道与TAG_DATETIME的区别 ## dateTimeDigitized=2020:05:23 08:13:17
val dateTimeDigitized = exifInterface.getAttribute(ExifInterface.TAG_DATETIME_DIGITIZED)
// 不懂 ## subSecTime=509580
val subSecTime = exifInterface.getAttribute(ExifInterface.TAG_SUBSEC_TIME)
// 白平衡模式,0自动,1手动 ## whiteBalance=0
val whiteBalance = exifInterface.getAttribute(ExifInterface.TAG_WHITE_BALANCE)
// 焦距,单位mm ## focalLength=3820/1000
val focalLength = exifInterface.getAttribute(ExifInterface.TAG_FOCAL_LENGTH)
// ## processingMethod=null
val processingMethod = exifInterface.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD)
}