How to save Exif data after bitmap compression in Android

孤街醉人 提交于 2019-12-19 07:16:09

问题


After taking a picture with the camera intent, I compress the bitmap to lower the file size. The problem is that after compression, it loses all EXIF data. I have no problem retrieving the original EXIF data, however, how do I add this EXIFF data after compression into the byte array ?

(My guess is to take the byte array and create a bitmap of that, then add the old EXIF data and thereafter add to byte array again, but this is a mobile application and I'm taking a lot of images so I don't want to waste memory)

Here is the code where I compress the bitmap and save to byte array output stream:

myBitmapImage.compress(Bitmap.CompressFormat.JPEG, 75, outputstream);//Losing EXIF data here
byte[] ba = outputstream.toByteArray(); // How to add EXIF data here ?

回答1:


I found a way in which we can save Exif data after bitmap compression hence posting it here if anyone come across this post.

You can use Apache's import for tiff and ExifTagConstants to add EXIF data back to the byte array image:
org.apache.sanselan.formats.tiff.constants.TagInfo org.apache.sanselan.formats.tiff.constants.ExifTagConstants



来源:https://stackoverflow.com/questions/23762133/how-to-save-exif-data-after-bitmap-compression-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!