繁体   English   中英

如何在不降低质量的情况下从图像(JPG)中删除元数据?

[英]How can I remove metadata from an image (JPG) without losing quality?

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

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

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

好吧,我最终通过使用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) {

            }
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM