Problems writing Exif Data

All your problems with Audio, Video and Images.

Problems writing Exif Data

Postby underminedsk » Fri Dec 10, 2010 3:21 am

Hi all,
I am trying to write exif data to JPG files using ExifInterface, but when I inspect the JPGs on my computer, they are devoid of any and all exif data.

More specifically, I am dumping frames using Camera.PreviewCallback and saving them as JPGs in the following way:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         public static void saveYUVImageData(byte[] previewBytes, String outFilePath, int compressionQuality) throws IOException {
  2.                 //first I decode the YUV frame data into RGB data
  3.                 int[] out = new int[previewBytes.length];
  4.                 decodeYUV420SP(out, previewBytes, CameraSettings.previewWidth, CameraSettings.previewHeight);
  6.                 //next I save the RGB data to a bitmap
  7.                 Bitmap myImage = Bitmap.createBitmap(out, CameraSettings.previewWidth, CameraSettings.previewHeight, Config.ARGB_8888);
  9.                 //next I write the Bitmap out to a file.
  10.                 FileOutputStream fileOutputStream = new FileOutputStream(outFilePath);         
  11.                 BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
  12.                 myImage.compress(CompressFormat.JPEG, compressionQuality, bos);
  13.                 bos.flush();
  14.                 bos.close();
  15.                 myImage.recycle();
  17.                 //and last I write the exif data to the file
  18.                 ExifInterface exif = new ExifInterface(filePath);
  19.                 exif.setAttribute("FocalLength", "43/10");
  20.                 exif.setAttribute("FocalPlaneResolutionUnits", "1");
  21.                 exif.setAttribute("FocalPlaneXResolution", "440/1");
  22.                 exif.setAttribute("FocalPlaneYResolution", "800/1");
  23.                 exif.saveAttributes();
  24.         }
Parsed in 0.033 seconds, using GeSHi

Has anyone experienced similar problems with ExifInterface? I read some forum posts on Stack Overflow that said that Bitmap.createBitmap() strips any exif data out of image - but since I'm using ExifInterface after using createBitmap(), it seems like it should work.

Alternative ways to solve this problem might be:
-find a different way to write the image data out in JPG format to the SDCard.
-find a 3rd party library to do that exif writing. I looked at one solution here: but it seems way too complicated for just simple exif tag writing.


Posts: 26
Joined: Tue Mar 02, 2010 3:36 am


Return to Multimedia Problems

Who is online

Users browsing this forum: Google Feedfetcher, Majestic-12 [Bot] and 8 guests