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

后端 未结 2 1707
心在旅途
心在旅途 2020-12-19 06:08

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?

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-19 06:40

    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"));
    

提交回复
热议问题