ExifInterface 不更新 exif 标签
我正在尝试使用 ExifInterface 更改 exif 标签。我使用 setAttribute() 并调用 saveAttributes()。标签被暂时保存,下次旧值仍然存在并且没有更新......
例如:
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"
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"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以防万一有人正在寻找纯 Android 解决方案:原始代码是正确的,但
TAG_ORIENTATION
属性的值必须是 1 到 8 之间的值,如 此页面。您必须抑制调用
readAttribute()
方法的行,该方法在 ExifInterface 类中不存在。如果您想读取修改前后的值,请将其替换为exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION, defaultValue)
。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 withexifInterface.getAttribute(ExifInterface.TAG_ORIENTATION, defaultValue)
if you want to read the value before and after the modification.另请确保您的应用程序具有 WRITE_EXTERNAL_STORAGE 权限
Also make sure your app has the WRITE_EXTERNAL_STORAGE permission
你应该使用类似的
东西
You should use something like
instead
试试这个:
Try this: