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