Why metadata is ignored when write a CMYK image?

47 views Asked by At

I am trying to write a CMYK image with imageio-jpeg.I want to keep the dpi same as the original image.I tried as follows.

IIOMetadata metadata = writer.getDefaultImageMetadata(new ImageTypeSpecifier(image), param);
Element tree = (Element) imageMetadata.getAsTree(JAVAX_IMAGEIO_JPEG_IMAGE_1_0);
IIOMetadataNode jpegMeta = new IIOMetadataNode(JAVAX_IMAGEIO_JPEG_IMAGE_1_0);
jpegMeta.appendChild(new IIOMetadataNode("JPEGVariety"));
jpegMeta.appendChild(tree.getElementsByTagName("markerSequence").item(0));
metadata.mergeTree(JAVAX_IMAGEIO_JPEG_IMAGE_1_0, jpegMeta);

writer.setOutput(output);
try {
    writer.write(null, new IIOImage(im, null, metadata), param);
} finally {
writer.dispose();
    output.flush();
}

Finally, com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageWriter#writeCMYK was called.In the writeCMYK method, image.metadata is never used, only delegate.getDefaultImageMetadata(destinationType, param) can be found here.How can I set up a metadata when I write a CMYK image? enter image description here

0

There are 0 answers