Get metadata in images with PNG format in android

0

Part of an application that I am developing, has to obtain the metadata of the images for its later use in it, until now 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 should be possible without using any library not provided by andorid, although this is not a requirement , I would also be better if it were not provided by android.

This is commented on if someone has done something similar or helps you provide some solution:

As a last option it would be to review the SKIA code and try to do something there "although if possible I do not know if that would be messing hands at least in my case "

UPDATE :

  • I do not need to write metadata on the image just to read it.
  • To be 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).
  • It would also be appreciated an example of use of the same or link to some type of documentation that indicates that it works for the propocito (but it is not a requirement).
asked by Angel Angel 14.01.2016 в 16:07
source

2 answers

4

How about PNGJ

It would be something like this

PngReader pngr = new PngReader(new File(archivoDeImagen));
pngr.getMetadata().getDpi() //obtiene dpi

This is the class Metadata You can see all the information you can get there

    
answered by 14.01.2016 / 17:05
source
2

You can use Metadata Xtractor , I have personally used it for .bmp files and it works perfectly, these are the supported formats:

Exif
IPTC
XMP
JFIF / JFXX
ICC Profiles
Photoshop fields
WebP properties
PNG properties
BMP properties
GIF properties
ICO properties
PCX properties

------------------------------
para PNG files
FileType.Png
------------------------------
para JPEG files
FileType.Jpeg
------------------------------
para TIFF y (mas) RAW files
FileType.Tiff

FileType.Arw
FileType.Cr2
FileType.Nef
FileType.Orf
FileType.Rw2
------------------------------
para Photoshop files
FileType.Psd
------------------------------
para BMP files
FileType.Bmp
------------------------------
para GIF files
FileType.Gif
------------------------------
para ICO files
FileType.Ico
------------------------------
para PCX files
FileType.Pcx
------------------------------
para WebP files
FileType.Riff
------------------------------
para RAF files
FileType.Raf

you just have to create an object Metadata

Metadata metadata = ImageMetadataReader.readMetadata(urlImagen);

and iterate over the tags it finds:

for (Directory directory : metadata.getDirectories()) {
    for (Tag tag : directory.getTags()) {
        System.out.println(tag);
    }
}

Here is the documentation

    
answered by 28.01.2016 в 18:45