且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android图像调整大小并保留EXIF数据(方向,旋转等)

更新时间:2023-11-21 12:22:16

正如其他人指出的那样,您必须将Exif数据从原始图像复制到最终调整大小的图像. Sanselan Android库通常最适合此功能.根据Android操作系统的版本,ExifInterface有时会破坏Exifdata.

As others have indicated, you must copy the Exif data from the original image to the final resized image. The Sanselan Android library is typically best for this. Depending on Android OS version, the ExifInterface sometimes corrupts the Exifdata.

此外,ExifInterface还处理有限数量的Exif标记,即仅处理其知道"的标记.另一方面,Sanselan将保留所有Exiftag和标记注释.

In addition, the ExifInterface also handles a limited number of Exif tags -- namely only the tags that it "knows" about. Sanselan on the other hand will keep all Exiftags and marker notes.

这是一篇博客文章,展示了如何使用Sanselan复制图像数据:

Here is a blog post that shows how to use Sanselan for copying image data:

使用Sanselan复制Exif元数据

顺便说一句,在Android上,我也倾向于旋转图像并删除Orientation Exiftag.例如,在具有Android 4.03的Nexus S上,摄像头在Exifmetadata中设置了方向标签,但Web视图忽略了该信息并错误地显示了图像.可悲的是,旋转实际图像数据并删除Exiforientation标签是使每个程序正确显示图像的唯一方法.

BTW, on Android I also tend to rotate the images and remove the Orientation Exiftag. For example, on a Nexus S with Android 4.03, the camera was setting an orientation tag in the Exifmetadata, but the webview was ignoring that information and displaying the image incorrectly. Sadly, rotating the actual image data and removing the Exiforientation tag is the only way to get every program to display images correctly.