Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中保存位图压缩后的Exif数据_Android_Exif_Android Camera Intent_Android Bitmap - Fatal编程技术网

如何在Android中保存位图压缩后的Exif数据

如何在Android中保存位图压缩后的Exif数据,android,exif,android-camera-intent,android-bitmap,Android,Exif,Android Camera Intent,Android Bitmap,在使用相机拍摄照片后,我压缩位图以减小文件大小。问题是压缩后,它会丢失所有EXIF数据。检索原始EXIF数据没有问题,但是,如何在压缩到字节数组后添加此EXIF数据 (我的猜测是获取字节数组并创建该数组的位图,然后添加旧的EXIF数据,然后再次添加到字节数组,但这是一个移动应用程序,我正在拍摄大量图像,因此我不想浪费内存) 下面是我压缩位图并保存到字节数组输出流的代码: myBitmapImage.compress(Bitmap.CompressFormat.JPEG, 75, outputst

在使用相机拍摄照片后,我压缩位图以减小文件大小。问题是压缩后,它会丢失所有EXIF数据。检索原始EXIF数据没有问题,但是,如何在压缩到字节数组后添加此EXIF数据

(我的猜测是获取字节数组并创建该数组的位图,然后添加旧的EXIF数据,然后再次添加到字节数组,但这是一个移动应用程序,我正在拍摄大量图像,因此我不想浪费内存)

下面是我压缩位图并保存到字节数组输出流的代码:

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

我找到了一种方法,我们可以保存位图压缩后的Exif数据,因此,如果有人看到这篇文章,就把它贴在这里

您可以使用Apache的导入tiff和ExifTagConstants将EXIF数据添加回字节数组映像:
org.apache.sanselan.formats.tiff.constants.TagInfo
org.apache.sanselan.formats.tiff.constants.ExifTagConstants