/************************************************************************** /* This class dumps image meta-information. /* /* Copyright (c) 2006 by Bernhard Bablok (mail@bablokb.de) /* /* This program is free software; you can redistribute it and/or modify /* it under the terms of the GNU General Public License as published /* by the Free Software Foundation; either version 2 of the License or /* (at your option) any later version. /* /* This program is distributed in the hope that it will be useful, but /* WITHOUT ANY WARRANTY; without even the implied warranty of /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /* GNU General Public License for more details. /* /* You should have received a copy of the GNU General Public License /* along with this program; see the file COPYING. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ import java.io.*; import java.util.*; import javax.imageio.*; import javax.imageio.stream.*; import javax.imageio.metadata.*; import org.w3c.dom.*; /** This class dumps image meta-information. @version $Revision: 1.3 $ @author $Author: bablokb $ */ public class PrintMeta { ////////////////////////////////////////////////////////////////////////////// /** Constructor. */ public PrintMeta() { } ////////////////////////////////////////////////////////////////////////////// /** Dump meta-data of a file to standard output. */ public void dump(File f) throws Exception { ImageReader reader = getReader(f); IIOMetadata metaData = reader.getImageMetadata(0); if (metaData == null) { System.out.println("no meta-data for file " + f.toString()); return; } String[] formats = metaData.getMetadataFormatNames(); for (int i=0; i"); // recursively print child tags while (child != null) { printNode(child,level+1); child = child.getNextSibling(); } indent(level); // start of closing tag System.out.println(""); } else { System.out.println("/>"); } } ////////////////////////////////////////////////////////////////////////////// /** Get a configured reader for the image. */ protected ImageReader getReader(File f) throws IOException { ImageInputStream iis = ImageIO.createImageInputStream(f); Iterator readers = ImageIO.getImageReaders(iis); ImageReader reader = (ImageReader) readers.next(); reader.setInput(iis,true); return reader; } ////////////////////////////////////////////////////////////////////////////// /** Iterate over all images. */ public void processImages(String[] args) throws Exception { for (int i=0; i