Android为图像文件创建自定义Exif属性 [英] Android Create Custom Exif attributes for an image file

查看:121
本文介绍了Android为图像文件创建自定义Exif属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在尝试将自定义exif标签/数据添加到相册中的图像文件中.

currently i am trying to add custom exif tag/data to an image file that is in photo album.

我能够修改 ExifInterface

I am able to modify the existing tags defined in ExifInterface class

但是,我想存储自定义数据,例如我的应用程序用户的用户ID,但似乎无法创建自定义exif属性

However, i want to store custom data, such as user id of my app user, but it seems there is no way i can create a custom exif attribute

我找到的最接近的解决方案是此处,但不起作用,

the closest solution I found is here, but does not work,

推荐答案

尝试使用以下标签保存Exif数据:

Try saving the Exif data with the tag:

用户评论"

"UserComment"

代码:

String mString = "Your message here";     
ExifInterface exif = new ExifInterface(path_of_your_jpeg_file);
exif.setAttribute("UserComment", mString);
exif.saveAttributes();

您可以在其中放入所需的任何内容(作为String),然后只需解析该字符串即可.我希望我们可以创建并命名自己的exif标签,但事实是我们做不到.因此,这是我想出的最佳解决方案.

You can put anything you want in there (as String) and simply parse the string. I wish we could create and name our own exif tags, but the reality is that we can't. So this is the best solution I came up with.

这篇关于Android为图像文件创建自定义Exif属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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