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

后端 未结 2 1706
心在旅途
心在旅途 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:20

    The Apache ExifRewriter:

    Reads a Jpeg image, removes all EXIF metadata (by removing the APP1 segment), and writes the result to a 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);
    

提交回复
热议问题