Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
457 views
in Technique[技术] by (71.8m points)

java - EXIF data in JPEG file

Write custom data as a Exif data in a JPEG image file using ExifInterface in Android

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)

Is this possible or any other alternative to maintain these short of information with image

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Android's ExifInterface only lets you write exif tags that are "recognized." You can find SOME of the recognized exif tags in the link: 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. Bad news is, I still haven't found a library that lists all usable exif tags

After researching and experimenting for hours, I found that the following tag works:

"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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...