3

我已经在 Stackoverflow 上找到了这个几乎相似的问题:

如何从 Java 中的 JPEG 图像中删除元数据?

但是当我使用上述方法时,保存的图像正在被压缩。有什么方法可以在不压缩图像的情况下删除元数据?有没有可以在我的 Java 程序中使用的库?

4

1 回答 1

4

好的,我终于找到了使用 Apache“commons-imaging”的解决方案:

https://svn.apache.org/repos/asf/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java

    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) {

            }
        }
    }
}
于 2013-07-10T09:53:27.223 回答