0

我想创建一个 jpg 并编辑它的 exif。
之前,我使用 ExifInterface:

ExifInterface exifInterface = new ExifInterface(filePath)
exifInterface.setAttribute(...)
exifInterface.setAttribute(...)
exifInterface.saveAttributes();

但在 Android Q 中,我只是从 MediaStore API 获得了一个图像 uri,而不是文件路径。我尝试使用它:

new ExifInterface(inputStream)

但是当我打电话时saveAttributes(),它显示如下

java.io.IOException: Failed to copy original file to temp file

那么,有没有另一种方法来处理这个问题

4

1 回答 1

1

我遇到过同样的问题。我通过在 build.gradle (app) 中将 ExifInterface 更新为 1.3.1 来解决它:

implementation 'androidx.exifinterface:exifinterface:1.3.1'

似乎与此提交有关saveAttributes,如发行说明中所示:https ://developer.android.com/jetpack/androidx/releases/exifinterface#1.3.1

Fix saveAttributes implementation to keep the image data in MediaProvider
于 2020-11-27T16:17:48.967 回答