Android读取图片当中的信息exif

在Android当中读取图片当中的信息,利用exifinterface类。

 

实例:

try {
			ExifInterface exif = new ExifInterface("/data/1111.jpg");
                   //照片拍摄的时间			
                       String time = exif.getAttribute(ExifInterface.TAG_DATETIME);
			//什么设备拍的照片
			//String modl = exif.getAttribute(ExifInterface.TAG_MODEL);
				
			
			System.out.println(time);
 
 
<span style="color:#000000;font: 14px/26px Arial; text-align: left; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">二、图片的MIMEExif信息
</span><span style="color:#000000;font: 14px/26px Arial; text-align: left; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"></span><p style="font: 14px/26px Arial; margin: 0px; padding: 0px; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><span style="font-size:14px;">  图片的的Exif信息和MP3的ID3标签类似,使用了属性和值的存储方式。通过publicvoidsetAttribute(Stringtag,Stringvalue)来设</span></p><p style="font: 14px/26px Arial; margin: 0px; padding: 0px; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><span style="font-size:14px;">置,而获取可以通过publicintgetAttributeInt(Stringtag,intdefaultValue)和publicStringgetAttribute(Stringtag)两种方法都可以,</span></p><p style="font: 14px/26px Arial; margin: 0px; padding: 0px; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><span style="font-size:14px;">getAttributeInt重载方法一第二个参数为我们设置的默认值,如果成功则返回相应Tag的值;特定的整数内容为该方法直接返回值。而</span></p><p style="font: 14px/26px Arial; margin: 0px; padding: 0px; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><span style="font-size:14px;">重载方法二该方法直接返回结果,如果失败则为null。</span></p><span style="color:#000000;font: 14px/26px Arial; text-align: left; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">  
  目前AndroidSDK定义的Tag有:
  TAG_DATETIME时间日期
  TAG_FLASH闪光灯
  TAG_GPS_LATITUDE纬度
  TAG_GPS_LATITUDE_REF纬度参考
  TAG_GPS_LONGITUDE经度
  TAG_GPS_LONGITUDE_REF经度参考
  TAG_IMAGE_LENGTH图片长
  TAG_IMAGE_WIDTH图片宽
  TAG_MAKE设备制造商
  TAG_MODEL设备型号
  TAG_ORIENTATION方向
  TAG_WHITE_BALANCE白平衡
</span><span style="color:#000000;font: 14px/26px Arial; text-align: left; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"></span><p style="font: 14px/26px Arial; margin: 0px; padding: 0px; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><span style="font-size:14px;">  </span></p><span style="color:#000000;font: 14px/26px Arial; text-align: left; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">  </span>


 

你可能感兴趣的:(Android读取图片当中的信息exif)