Hello guys
We are creating a file which have some information about file i.e create date, modify date, tags and description etc. called metadata of the file.
Now, We are extract the Imagedata using javax.imageIO package requires ImageInputStreams and Readers, for better understanding see below example
ImageInputStream iis = ImageIO.createImageInputStream(
new BufferedInputStream(
new FileInputStream(file)));
Iterator readers =
ImageIO.getImageReadersByMIMEType("image/jpeg");
IIOImage image = null;
if (readers.hasNext()) {
ImageReader reader = readers.next();
reader.setInput(iis, true);
try {
image = reader.readAll(0, null);
} catch (javax.imageio.IIOException iioex) {...}
IIOMetadata metadata = image.getMetadata();
String[] names = metadata.getMetadataFormatNames();
for (int i = 0; i < length; i++) {
if (log.isDebugEnabled()) {
log.debug("Format name: " + names[ i]);
log.debug(displayMetadata(metadata.getAsTree(names[i])));
}
}
}
0 Comment(s)