开发者

Using the Android SDK i'm not seeing any EXIF in my JPEG's

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开发者_JAVA百科'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


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);


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 :)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜