Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Getting all existing exif data from an image

Tags:

android

exif

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?

like image 786
Aneem Avatar asked Jun 08 '12 18:06

Aneem


People also ask

How do you get all details of an image pragmatically available in Android Gallery?

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.

How do I get metadata from a picture on Android?

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.

Does Android save EXIF data?

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.


1 Answers

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 }
like image 138
android developer Avatar answered Nov 14 '22 23:11

android developer