Part of an application that I am developing, has to obtain the metadata of the images for its later use in it, so far what I am using is ExifInterface , with something similar to the following:
//..
String filename = "DirectorioDondeEstaElFichero/DSC_.JPG";
try {
ExifInterface exif = new ExifInterface(filename);
FiltroExif(exif);
//ShowExif(exif);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
//..
}
//..
private void FiltroExif(ExifInterface exif){
String attr="attr ---\n";
attr += getTagString(ExifInterface.TAG_DATETIME, exif);
attr += getTagString(ExifInterface.TAG_GPS_LATITUDE, exif);
attr += getTagString(ExifInterface.TAG_GPS_LATITUDE_REF, exif);
}
//..
But as the documentation says at some point:
This is a class for reading and writing Exif tags in a JPEG file.
There is some known way to read the metadata of an image PNG
if it is possible without using any library not provided by android, although this is not a requirement , it would also be worth it if it was not provided by android.
This is commented in case someone has done something similar or helps provide a solution:
As a last option, it would be to review the SKIA code and try to do something there "although if possible I don't know if that would be muddying my hands at least in my case "
UPDATE :
- I don't need to write metadata to the image just read it.
- If it is an external library that has time to be created or used, to avoid bugs that may appear in the process of using it (but it is not a requirement).
- An example of its use or a link to some type of documentation that indicates that it works for the purpose would also be appreciated (but it is not a requirement).
How about PNGJ?
It would be something similar to this
This is the Metadata class you can see there all the information you can get
You can use
Metadata Xtractor
, I have personally used it for files.bmp
and it works perfectly, these are the supported formats:you just have to create an object
Metadata
and iterate over the tags it finds:
Here is the documentation