How can I remove metadata from a JPEG image in Jav

2019-01-26 14:31发布

问题:

I'm trying to remove metadata from a .jpg file and replace it with nothing. Can anyone provide an example of how I might do this?

回答1:

Metadata isn't read when you read in the image. So just read it in and write it back.

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