我已经在 Stackoverflow 上找到了这个几乎相似的问题:
但是当我使用上述方法时,保存的图像正在被压缩。有什么方法可以在不压缩图像的情况下删除元数据?有没有可以在我的 Java 程序中使用的库?
我已经在 Stackoverflow 上找到了这个几乎相似的问题:
但是当我使用上述方法时,保存的图像正在被压缩。有什么方法可以在不压缩图像的情况下删除元数据?有没有可以在我的 Java 程序中使用的库?
好的,我终于找到了使用 Apache“commons-imaging”的解决方案:
public void removeExifMetadata(final File jpegImageFile, final File dst)
throws IOException, ImageReadException, ImageWriteException {
OutputStream os = null;
try {
os = new FileOutputStream(dst);
os = new BufferedOutputStream(os);
new ExifRewriter().removeExifMetadata(jpegImageFile, os);
} finally {
if (os != null) {
try {
os.close();
} catch (final IOException e) {
}
}
}
}