1

Currently I am trying to download an Image from a Webserver and retain the Exif data which are attached to the picture. Downloading the image itself is no problem at all. Example Code is like this (without any try/catch or AsyncTask related code to make it readable)

final HttpGet request = new HttpGet("IMAGE_URL");
final AndroidHttpClient httpClient = AndroidHttpClient.newInstance("Android");

HttpResponse response   = httpClient.execute(request);
InputStream inputStream = inputStream = response.getEntity().getContent();

Now I simply would call the BitmapFactory to create a Bitmap object from the Inputstream like this

BitmapFactory.decodeStream(inputStream);

First I thought the BitmapFactory is the culprit and tried to read the Exif data from a file created from the inputstream. The ExifInterface can't get the Exif data and opened on Windows the saved image has no Exif at all.

everald
  • 118
  • 2
  • 8

1 Answers1

1

Android Api won't allow you to read exif data from a Stream, only from a File. For more info you can use this link : Reading android jpeg EXIF metadata

Download metadata extractor from the link given Click Here to download the library choose the version 2.5.0.RC-3.zip

Extract the jar Folder and import jar into libs folder in your poject and then execute the below code

try 
{
    InputStream is = new URL("your image url").openStream();
    BufferedInputStream bis = new BufferedInputStream(is);
    Metadata metadata = ImageMetadataReader.readMetadata(bis,true);

    for (Directory directory : metadata.getDirectories()) 
    {
        for (Tag tag : directory.getTags()) 
        {
            System.out.println(tag);
        }
    }
}
catch (ImageProcessingException e){}
catch (IOException e) {}
Community
  • 1
  • 1
Harish Godara
  • 2,388
  • 1
  • 14
  • 28
  • I already tried to use a newer version of this library, but my project wasn't building anymore so I skipped this solution. Maybe I give it another shot with this version. – everald Sep 17 '13 at 13:42
  • Works well still in 2023. The library is updated yearly. – fengelhardt Mar 27 '23 at 01:32