Android 实现对图片 Exif 的修改(Android 自带的方法)
2016-05-11 21:29
691 查看
很多时候我们都要对我们的图片信息进行一些处理,比如向图片中写入经纬度,拍摄时间,设备信息,作者等等。
这个时候我们就要对我们的图片Exif进行写入信息的操作,当然,我们想知道图片的Exif信息,也可以对Exif信息的读取操作。
因为Android本身有对图片Exif操作的方法,所以就不需要额外导入其他 jar
下面先贴出代码:
相应文章分享:
http://blog.csdn.net/xywy2008/article/details/38089789 http://blog.csdn.net/gao_chun/article/details/46854323 http://blog.csdn.net/fengyud/article/details/6147597 http://blog.csdn.net/kook_okko/article/details/2635294 http://blog.csdn.net/dc15822445347/article/details/8142103
这个时候我们就要对我们的图片Exif进行写入信息的操作,当然,我们想知道图片的Exif信息,也可以对Exif信息的读取操作。
因为Android本身有对图片Exif操作的方法,所以就不需要额外导入其他 jar
下面先贴出代码:
<span style="font-size:14px;">import android.media.ExifInterface; import android.util.Log; import java.io.IOException; /** * Created by long on 2016/3/22. */ public class ModifyExif { private static ExifInterface exif = null; //设置exif public static void setExif (String filepath,String longitude,String latitude,String time){ try{ exif = new ExifInterface(filepath); //根据图片的路径获取图片的Exif }catch (IOException ex){ Log.e("Mine","cannot read exif",ex); } exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE,longitude); //把经度写进exif exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, latitude); //把纬度写进exif exif.setAttribute(ExifInterface.TAG_DATETIME,time); //把时间写进exif exif.setAttribute(ExifInterface.TAG_MAKE,longitude); //把经度写进MAKE 设备的制造商,当然这样也是可以的,大家都是Stirng类型 exif.setAttribute(ExifInterface.TAG_MODEL,latitude); //把纬度写进MODEL try{ exif.saveAttributes(); //最后保存起来 }catch (IOException e){ Log.e("Mine","cannot save exif",e); } } //获取exif public static ExifInterface getExif(String filepath){ try { exif = new ExifInterface(filepath); //想要获取相应的值:exif.getAttribute("对应的key");比如获取时间:exif.getAttribute(ExifInterface.TAG_DATETIME); } catch (Exception e) { e.printStackTrace(); } return exif; } <span style="font-family: Arial, Helvetica, sans-serif;">}</span></span>
相应文章分享:
http://blog.csdn.net/xywy2008/article/details/38089789 http://blog.csdn.net/gao_chun/article/details/46854323 http://blog.csdn.net/fengyud/article/details/6147597 http://blog.csdn.net/kook_okko/article/details/2635294 http://blog.csdn.net/dc15822445347/article/details/8142103
相关文章推荐
- android 6.0权限适配哥哥踩过的坑
- 关于android硬编h264----一小白踩得坑
- Android性能优化之布局优化
- android错误之MediaPlayer用法的Media Player called in state *
- Android M版本和非M版本动态权限适配方案---续篇
- Android AutoCompleteTextView
- Android Studio中文件颜色的意义
- 【Android】注解机制详解
- Android广播机制
- Android 开源项目浅读-------SwipeMenuListView-重写-第一章-手指移动事件捕获
- Android之自定义标题--使用自定义Layout
- Android Studio报错,Error:SSL peer shut down incorrectly
- Android 开源项目浅读-------SwipeMenuListView
- android pd px sp 转换
- android一句话搞定图片加载
- android中xml tools:属性详解
- android中播放本地raw下的文件
- android基础学习之fragment+viewpager+fragment事件听
- Android程序报错,不能再console捕捉并定位到错误行,怎么办?
- 在源码环境中编译Android studio项目时的mk脚本编写