I know it's possible to get specific exif data by specifying the string tag in the ExifInterface. For example, getting the date of an image would be something like:
ExifInterface exif = new ExifInterface(pathToImage);
exif.getAttribute(ExifInterface.TAG_DATETIME);
Is there a way to simply get all of the non-null available exif strings without having to manually write the get code for each of them?
you can use android's ExifInterface for doing this. This is a class for reading and writing Exif tags in a JPEG file or a RAW image file. Supported formats are: JPEG, DNG, CR2, NEF, NRW, ARW, RW2, ORF and RAF. Thanks @Akshay you save my day.
Follow these steps to view EXIF data on your Android smartphone. Open Google Photos on the phone - install it if needed. Open any photo and tap the i icon. This will show you all the EXIF data you need.
Checking the Exif data of a photo on an Android phone or tablet is pretty easy. You don't need access to any special apps. The gallery app of your phone or Google Photos can show the most important bits from the Exif data of your photos.
you can make an array of all tags that you wish to query, and put the non-null results of the query into a collection (maybe hashmap) or something else (maybe JsonObject).
Example in Kotlin:
val pathToImage = "..."
val exif = ExifInterface(pathToImage)
val tagsToCheck = arrayOf(
ExifInterface.TAG_DATETIME,
ExifInterface.TAG_GPS_LATITUDE,
ExifInterface.TAG_GPS_LONGITUDE,
ExifInterface.TAG_EXPOSURE_TIME
)
val hashMap = HashMap<String, String>()
for (tag in tagsToCheck)
exif.getAttribute(tag)?.let { hashMap[tag] = it }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With