This code sample demonstrates how to add a custom tag to an EXIF package
Java
try (Metadata metadata = new Metadata("input.tiff")) {
IExif root = (IExif) metadata.getRootPackage();
// Set the EXIF package if it's missing
if (root.getExifPackage() == null) {
root.setExifPackage(new ExifPackage());
}
// Add a known property
root.getExifPackage().set(new TiffAsciiTag(TiffTagID.Artist, "Artist's name"));
// Add a fully custom property (which is not described in the EXIF specification)
// Please note that the chosen ID may intersect with the IDs used by some third party tools
root.getExifPackage().set(new TiffAsciiTag(TiffTagID.getByRawValue(65523), "Hidden data"));
metadata.save("output.tiff");
}