GeoTiffIIOMetadataEncoder geoTIFFMetadata, ImageWriteParam params) throws IIOException {
IIOMetadata imageMetadata = writer.getDefaultImageMetadata(type, params);
imageMetadata = writer.convertImageMetadata(imageMetadata, type, params);
org.w3c.dom.Element w3cElement = (org.w3c.dom.Element) imageMetadata
.getAsTree(GeoTiffConstants.GEOTIFF_IIO_METADATA_FORMAT_NAME);
final Element element = new DOMBuilder().build(w3cElement);
geoTIFFMetadata.assignTo(element);
final Parent parent = element.getParent();
parent.removeContent(element);