8

I'm using the android.hardware.Camera class to take pictures and i'm finding that no exif data is stored in the images at all. If i use the camera application on my DROID all of the exif data is being saved.

I've tried setting the rotation with Set() and SetRotation() to see if I can get some exif data to show up. When I view the images on my laptop with an exif reader it tells me the image has NO exif data.

I've seen some similar posts, but I have not found a solution to this. Has anyone seen this issue with other phones?

I'm using the Android 2.0.1 SDK

2
  • So this is what I don't understand. When I take a picture with the camera API, I am expecting to get an image with EXIF data present. The ImageData should contain all the information from the camera like. The Exposure time, F Number, ISO, Shutter Speed, etc... Why isn't this information provided when using the Camera API? Commented Feb 24, 2010 at 21:33
  • See Sanselan implementation Commented May 11, 2011 at 7:51

3 Answers 3

13

So after some more research I found that I was loosing the EXIF information when i used the following code to save the image data to the SD card.

BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 0; Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length); FullFileName = sdImageMainDirectory.toString() + "/DCIM/Camera/" + getDateTime() + ".jpg"; fileOutputStream = new FileOutputStream(FullFileName); BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream); myImage.compress(CompressFormat.JPEG, quality, bos); bos.flush(); bos.close(); 

I changed the above code to simply be this, and now all the EXIF data from the camera is present.

FileOutputStream file = new FileOutputStream(FileName); file.write(imageData); 
Sign up to request clarification or add additional context in comments.

2 Comments

how did you get byte[] imageData?
using the android camera api onPictureTaken returns the image as a byte array developer.android.com/reference/android/hardware/…
2

Thanks scntln!

I'm using this indeed in my Camera FX app. It works well for embedding EXIF tags in JPEGS (not in PNG files).

Android SDK version 2.x has its own ExifInterface class that you could use instead. But if you need to support 1.6 or lower, then my sanselandroid port should work fine.

I'm still in the process of pruning the sanselanandroid project more to contain only what's absolutely necessary for just writing EXIF tags.

BTW: I noticed here that I spelled 'compatiable' incorrectly. Fixed that on my blog :)

Comments

1

It appears from posts like this that the camera class does not support EXIF data, and the camera application uses its own EXIF implementation.

One option would be to browse the source that is mentioned in that thread and see if there is anything that you can use.

Another option would be the sanselandandroid project. The developer admits that it is not a perfect port, but he developer is a somewhat active participant in the android centric Google groups and sells his own camera software Snap FX which includes an application named Camera FX that saves EXIF data according to the product page.

Good luck.

Pictures are saved with EXIF tags that are compatiable with most software editing applications.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.