1

How do I save GPS_IMG_DIRECTION tag to an image in android? I have check the following exifinterface link, but it does not seem to have GPS_IMG_DIRECTION.

http://developer.android.com/reference/android/media/ExifInterface.html

I have tried to add customtag by using this:

exifTags.setAttribute("TAG_GPS_IMG_DIRECTION", "123"); exifTags.setAttribute("TAG_GPS_IMG_DIRECTION_REF", "M"); 

But this doesn't seem to work. I also tried to use the hexadecimal value of the tag by :

 exifTags.setAttribute("0x0011", "123"); 

But this too doesn't seem to work. Any ideas?

2 Answers 2

1

TAG_GPS_IMG_DIRECTION is a Java constant. The underlying EXIF attribute is GPSImgDirection. Also, for an azimuth of 45.5°, the value should be formatted as "4550/100". The resulting that worked for me is:

val exif = ExifInterface(file) val imageDirectionAsString = (imageDirection * 100).roundToInt().toString() + "/100" exif.setAttribute(ExifInterface.TAG_GPS_IMG_DIRECTION, imageDirectionAsString) 
Sign up to request clarification or add additional context in comments.

1 Comment

Side question: Do you know if TAG_GPS_IMG_DIRECTION_REF should be specified when adding the direction angle to the EXIF metadata. And if yes, should 0 be added, because representing North?
0

Google's ExifInterface supported very limited number of tags. You need to add this tag by yourself. For this purpose you may look at

http://rcs34-android.blogspot.ru/2012/09/exif-metadata-handler-for-android-pure.html https://code.google.com/p/exif-driver/source/browse/src/rcs34/android/libs/ExifDriver/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.