Question

I already found this nearly similar question on Stackoverflow:

How can I remove metadata from a JPEG image in Java?

But when I use the Method described above, the saved image is being compressed. Is there any way to remove the metadata without compressing the image? Is there any library that I could use in my Java-Program?

Was it helpful?

Solution

Ok, I finaly found a solution by using 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) {

            }
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top