// TODO: should be an eRewriter to get back the Exif part!
IImageMetadata metaData = Sanselan.getMetadata(f);
JpegImageMetadata jMetaData = (JpegImageMetadata) metaData;
assert (jMetaData != null);
TiffImageMetadata exif = jMetaData.getExif();
TiffOutputSet outputSet = exif.getOutputSet();
TiffOutputField field = outputSet.findField(TiffConstants.EXIF_TAG_PROCESSING_SOFTWARE);
if (null != field) {
outputSet.removeField(TiffConstants.EXIF_TAG_PROCESSING_SOFTWARE);
String fieldString = "Edited by DeExifier. andreas.reichart@gmail.com";
TiffOutputField newField = new TiffOutputField(ExifTagConstants.EXIF_TAG_PROCESSING_SOFTWARE,
TiffFieldTypeConstants.FIELD_TYPE_ASCII, fieldString.length(), fieldString.getBytes());
TiffOutputDirectory outDirectory = outputSet.getOrCreateExifDirectory();
outDirectory.add(newField);
}
eRewriter.updateExifMetadataLossless(imageByte, bOutputStream, outputSet);
}
// if (removeExif & removeIptc) {
// TODO: removeExif & removeIptc
// }
// OK, works: recompressed image is already empty.
if (!removeExif && !removeIptc) {
IImageMetadata metadata = Sanselan.getMetadata(f);
JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
if (jpegMetadata != null) {
TiffImageMetadata exif = jpegMetadata.getExif();
if (exif != null) {
TiffOutputSet outputSet = exif.getOutputSet();
TiffOutputSet emptySet = new TiffOutputSet();
new ExifRewriter().removeExifMetadata(imageByte, bOutputStream);
}
}
}