我有一个字节数组形式的JPEG图像。 我怎样才能获得的形式,我可以剥夺元数据的注释节点的字节数组?
byte[] myimagedata = ...
ImageWriter writer = ImageIO.getImageWritersBySuffix("jpeg").next();
ImageReader reader = ImageIO.getImageReader(writer);
//Looking for file here but have byte array
reader.setInput(new FileImageInputStream(new File(Byte array cant go here)));
IIOMetadata imageMetadata = reader.getImageMetadata(0);
Element tree = (Element) imageMetadata.getAsTree("javax_imageio_jpeg_image_1.0");
NodeList comNL = tree.getElementsByTagName("com");
IIOMetadataNode comNode;
if (comNL.getLength() == 0) {
comNode = new IIOMetadataNode("com");
Node markerSequenceNode = tree.getElementsByTagName("markerSequence").item(0);
markerSequenceNode.insertBefore(comNode,markerSequenceNode.getFirstChild());
} else {
comNode = (IIOMetadataNode) comNL.item(0);
}