File tempFile = createTempFile("removed", ".jpg");
Debug.debug("tempFile", tempFile);
IOUtils.writeToFile(bytes, tempFile);
Debug.debug("Output Segments:");
stripped = new ByteSourceArray(bytes);
new JpegUtils().dumpJFIF(stripped);
assertTrue(!hasExifData(tempFile));
}
{
TiffOutputSet outputSet = oldExifMetadata.getOutputSet();
// outputSet.dump();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ExifRewriter().updateExifMetadataLossy(stripped, baos,
outputSet);
byte bytes[] = baos.toByteArray();
File tempFile = createTempFile("inserted" + "_", ".jpg");
Debug.debug("tempFile", tempFile);
IOUtils.writeToFile(bytes, tempFile);
Debug.debug("Output Segments:");
new JpegUtils().dumpJFIF(new ByteSourceArray(bytes));
// assertTrue(!hasExifData(tempFile));
JpegImageMetadata newMetadata = (JpegImageMetadata) Sanselan
.getMetadata(tempFile);