How to remove metadata from a jpeg image in Java?

I am trying to remove metadata from a .jpg file and replace it with nothing. Can someone provide an example of how I can do this?

+6
source share
2 answers

Metadata is not readable when you read the image. So just read it and write back.

BufferedImage image = ImageIO.read(new File("image.jpg"));
ImageIO.write(image, "jpg", new File("image.jpg"));
+6
source

Apache ExifRewriter :

Reads the image in Jpeg format, deletes all EXIF ​​metadata (deleting the APP1 segment) and writes the result to the stream.

FileInputStream is = new FileInputStream(new File("/path/to/photo.jpg"));
FileOutputStream os = new FileOutputStream(new File("/path/to/photo_without.jpg"))) 

new ExifRewriter().removeExifMetadata(is, os);
0
source

All Articles