ExifInterface不更新EXIF标签 [英] ExifInterface doesn't update exif tags

查看:103
本文介绍了ExifInterface不更新EXIF标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变EXIF标签与ExifInterface。我使用的setAttribute()并调用saveAttributes()。标签被暂时保存,那么下一次的旧值仍然存在,一直没有更新...........

例如:

  ExifInterface exifInterface =新ExifInterface(文件路径);

字符串01 = exifInterface.readAttribute(TAG_ORIENTATION); // o1的是0

exifInterface.setAttribute(TAG_ORIENTATION,90);
exifInterface.saveAttributes();

字符串O2 = exifInterface.readAttribute(TAG_ORIENTATION); // O2是90后

//重新启动应用程序,读取属性相同的照片

字符串O3 = exifInterface.readAttribute(TAG_ORIENTATION); // O3为0再次,前人的精力是90
 

解决方案

万一有人找一个纯粹的Andr​​oid解决方案:原来的code是正确的,但价值 TAG_ORIENTATION 属性,必须在1和8之间的值,如解释了这个页面

您必须要喝preSS与呼叫该行 readAttribute()的方法,这种方法不会在ExifInterface类存在。与 exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION,设置defaultValue)如果你想之前和修改后读值。

替换它

I'm trying to change exif tags with ExifInterface. I use setAttribute() and call saveAttributes(). The tag is saved temporarily, then next time the old value is still there and hasn't been updated................

Example:

ExifInterface exifInterface = new ExifInterface(filePath);

String o1 = exifInterface.readAttribute(TAG_ORIENTATION); //o1 is "0"

exifInterface.setAttribute(TAG_ORIENTATION, "90");
exifInterface.saveAttributes();

String o2 = exifInterface.readAttribute(TAG_ORIENTATION); //o2 is "90"

// relaunch app, read attribute for same photo

String o3 = exifInterface.readAttribute(TAG_ORIENTATION); //o3 is "0" again, sould be "90"

解决方案

Just in case someone is looking for a pure android solution: original code is correct, but value of TAG_ORIENTATION attribute must be a value between 1 and 8, as explained in this page.

You must suppress the line with the call to readAttribute() method, this method doesn't exist in the ExifInterface class. Replace it with exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION, defaultValue) if you want to read the value before and after the modification.

这篇关于ExifInterface不更新EXIF标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆