android img标签属性_在Android中将EXIF标签(属性)写入并保存到JPEG图像

我已经设法使用ExifInterface从手机上的JPEG中读取EXIF标签/属性(元数据),我显然也可以设置属性和保存属性.奇怪的是,如果我在图像文件上设置保存,我的应用程序可以获取属性并显示它.我还可以在另一个应用程序(Google Play上的照片编辑器)中验证EXIF数据确实已写入.

ExifInterface exif = new ExifInterface(path_to_image);

String x = exif.getAttribute("UserComment"); // here, x is always null...

exif.setAttribute("UserComment", "testtest");

exif.saveAttributes();

x = exif.getAttribute("UserComment"); // x = "testtest"

但是,如果我注释掉set save并且只是得到(在与上面相同的图像上),我的应用程序无法获取/查看属性:

ExifInterface exif = new ExifInterface(path_to_image);

String x = exif.getAttribute("UserComment"); // x = null (although we know it isn't)

所以:由于照片编辑器应用程序可以读取数据,我做错了(写入/保存).此外,如果我在同一个图像文件上重新运行set save,我的应用程序会复制相同的标签!除了简单设置保存之外还有更多内容吗?

Update: It seems the problem is device-dependent. Although the UserComment does not appear to be among the tags explicitly supported by ExifInterface, certain devices are nevertheless able to set and get the value in the tag. It works on Nexus’es, but not on my Sony Xperia. Please take a look at my code for getting (query) and setting (update) the UserComment tag 07002

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值