获取照片的exif信息

其实关于照片的大小 像素 拍摄所用的相机,等一系列的信息都在照片的头信息中

也是使用android自带的类使用的,直接代码吧

 1 package cn.itcast.exit;
 2 
 3 import java.io.IOException;
 4 
 5 import android.app.Activity;
 6 import android.media.ExifInterface;
 7 import android.os.Bundle;
 8 
 9 public class ExifActivity extends Activity {
10     /** Called when the activity is first created. */
11     @Override
12     public void onCreate(Bundle savedInstanceState) {
13         super.onCreate(savedInstanceState);
14         setContentView(R.layout.main);
15         try {
16             ExifInterface exif = new ExifInterface("/sdcard/img.JPG");
17             String time  = exif.getAttribute(ExifInterface.TAG_DATETIME);
18             System.out.println(time);
19             exif.setAttribute("camera", "我是用柯达相机拍摄的");
20             
21             
22             System.out.println(exif.getAttribute("camera"));
23         } catch (Exception e) {
24             e.printStackTrace();
25         }
26     }
27 }

 

posted @ 2013-01-27 13:14  王世桢  阅读(394)  评论(0编辑  收藏  举报