moleculeone
moleculeone

Reputation: 221

Saving GPS Image Direction tag in android

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?

Upvotes: 1

Views: 1207

Answers (2)

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)

Upvotes: 1

Maxim Metelskiy
Maxim Metelskiy

Reputation: 1389

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/

Upvotes: 0

Related Questions