我已经在 Stackoverflow 上找到了这个几乎相似的问题:
How can I remove metadata from a JPEG image in Java?
但是当我使用上述方法时,保存的图像正在被压缩。有没有办法在不压缩图像的情况下删除元数据?我可以在我的 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) {
}
}
}
}
关于java - 如何在不降低质量的情况下从图像 (JPG) 中删除元数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17552031/