problems extracting EXIF data from image using MediaStore

All your problems with Audio, Video and Images.

problems extracting EXIF data from image using MediaStore

Postby roblu » Wed Aug 04, 2010 9:41 am

Hello.

I want to get the EXIF data from a jpg image.
I am doing this with MediaStore. It looks like that:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Cursor c = this.managedQuery(uri,
  2.                 new String[]{
  3.                         MediaStore.Images.ImageColumns.DATA,
  4.                         MediaStore.Images.ImageColumns.TITLE,
  5.                         MediaStore.Images.ImageColumns.DESCRIPTION,
  6.                         MediaStore.Images.ImageColumns.DATE_TAKEN,
  7.                         MediaStore.Images.ImageColumns.LATITUDE,
  8.                         MediaStore.Images.ImageColumns.LONGITUDE,
  9.                         MediaStore.Images.ImageColumns.SIZE,
  10.                 }, null, null, null);
  11.  
  12. String path=null, title=null, description=null;
  13. long datetaken=-1;
  14. double latitude=0.0, longitude=0.0;
  15.  
  16. if (c != null && c.getCount() > 0) {
  17.         c.moveToFirst();
  18.         path            = c.getString(c.getColumnIndex(MediaStore.Images.ImageColumns.DATA));
  19.         title           = c.getString(c.getColumnIndex(MediaStore.Images.ImageColumns.TITLE));
  20.         description     = c.getString(c.getColumnIndex(MediaStore.Images.ImageColumns.DESCRIPTION));
  21.         datetaken       = c.getLong(c.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN));
  22.         latitude        = c.getDouble(c.getColumnIndex(MediaStore.Images.ImageColumns.LATITUDE));
  23.         longitude       = c.getDouble(c.getColumnIndex(MediaStore.Images.ImageColumns.LONGITUDE));
  24. }
  25.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

I tested it with some sample pictures an it works fine on Android2.1-Emulators and on my Motorola Milestone (also 2.1). But on Android1.6-Emulators I have the problem, that datetaken is always 0.
Does anybody know why it is so and what I can do to fix this?

I could also try ExifInterface, but it is included since API Level 5 and I want to run my application on Android 1.6.

I would be glad, if anyone could help me.
roblu
Freshman
Freshman
 
Posts: 3
Joined: Wed Aug 04, 2010 9:19 am

Top

Re: problems extracting EXIF data from image using MediaStor

Postby blundell » Wed Aug 04, 2010 11:20 am

Are you sure that the 1.6 camera just doesn't save that data? i.e. have you tested the same image on the two devices? or take the image on the 1.6 device then use it on a 2.1
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: problems extracting EXIF data from image using MediaStor

Postby roblu » Wed Aug 04, 2010 2:11 pm

My test images come from the camera of my milestone (2.1), from my friends Android1.5 phone and from the internet. I have checked the exif data with IrvanView: every photo has correct data, especially datetaken is set.

For testing, I put the same test images on the sdcard of the emulators. In Android 2.1 everything works fine - in Android 1.6 datetaken is always 0.
roblu
Freshman
Freshman
 
Posts: 3
Joined: Wed Aug 04, 2010 9:19 am

Re: problems extracting EXIF data from image using MediaStor

Postby blundell » Wed Aug 04, 2010 2:31 pm

Don't trust the emulators :-) I'd recommend trying it on a device running 1.6, if you haven't got one IRL you could use : http://www.perfectomobile.com they'll give you an hour's free testing, more than enough ;-)
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: problems extracting EXIF data from image using MediaStor

Postby roblu » Wed Aug 04, 2010 4:26 pm

I tried it with an 1.6 device on perfectomobile (by the way: cool service!) and it works. So it really only seems to be a problem with the emulator.

Thank you for your help. :)
roblu
Freshman
Freshman
 
Posts: 3
Joined: Wed Aug 04, 2010 9:19 am

Re: problems extracting EXIF data from image using MediaStor

Postby blundell » Wed Aug 04, 2010 4:34 pm

Yeah the emulators are SH*T in certain area's.

no problem :-D
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 5 guests