简体   繁体   English

JPEG文件中的EXIF数据

[英]EXIF data in JPEG file

Write custom data as a Exif data in a JPEG image file using ExifInterface in Android 使用Android中的ExifInterface将自定义数据作为Exif data in a JPEG image file写入Exif data in a JPEG image file

Would like to write/add custom tags/exif data in JPEG file like name, age, etc... Right now i am able to write default values like Geo location data, attributes etc... but can i write custom data in JPEG image using ExifInterface (Android) 想在JPEG file write/add自定义tags/exif数据,如姓名,年龄等...现在我可以编写默认值,如Geo location data, attributes etc...但我可以用JPEG编写自定义数据使用ExifInterface (Android)图像

Is this possible or any other alternative to maintain these short of information with image 这是否可能或任何其他替代方案,以保持图像的这些信息不足

Android's ExifInterface only lets you write exif tags that are "recognized." Android的ExifInterface只允许您编写“已识别”的exif标记。 You can find SOME of the recognized exif tags in the link: http://developer.android.com/reference/android/media/ExifInterface.html 您可以在链接中找到一些公认的exif标记: http//developer.android.com/reference/android/media/ExifInterface.html

But the good news is, there's more exif tags that's not mentioned in the Android API. 但好消息是,Android API中没有提到更多exif标签。 Bad news is, I still haven't found a library that lists all usable exif tags 坏消息是,我还没有找到列出所有可用exif标签的库

After researching and experimenting for hours, I found that the following tag works: 经过几个小时的研究和实验,我发现以下标签有效:

"UserComment" “UserComment在”

So the following code snippet will work: 因此,以下代码段将起作用:

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

I'm still trying to find out which other exif tags are allowed, but for now, this should do the trick. 我仍然试图找出允许哪些其他exif标签,但是现在,这应该可以解决问题。

To do this use the Android EXIF Interface 为此,请使用Android EXIF界面

  1. Add your Attributes using this method public void setAttribute (String tag, String value) 使用此方法添加属性public void setAttribute(String tag,String value)

  2. Make a new version of the JPEG with this method. 使用此方法创建JPEG的新版本。 public void saveAttributes () public void saveAttributes()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM