List of usage examples for org.apache.commons.imaging.formats.tiff.taginfos TagInfo getDescription
public String getDescription()
From source file:de.aikiit.fotorenamer.image.MetaDataExtractor.java
/** * Returns the requested tag as String from the image file. * * @param image Image file to extract Metadata from. * @param tag Tag to extract from the given file, @see TiffConstants * @return Returns exif tag value, in case of any errors the value is an * empty String.// w w w . ja v a2 s .co m * @throws IOException if file cannot be accessed. * @throws ImageReadException if an error occurred during image processing. */ public static String getExifMetadata(final File image, final TagInfo tag) throws IOException, ImageReadException { assert image != null : "Parameter image must not be null"; assert tag != null : "Parameter tag must not be null"; String result = EMPTY_STRING; ImageMetadata metadata = Imaging.getMetadata(image); /* for(ImageMetadata.ImageMetadataItem item:metadata.getItems()) { System.out.println("WWW: " + item.getSelectedDirectory()); } */ if (metadata instanceof JpegImageMetadata) { JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; TiffField field = jpegMetadata.findEXIFValueWithExactMatch(tag); if (field != null) { result = field.getValueDescription(); LOG.info("extraction of " + tag.getDescription() + " yields " + result); } } return (result == null ? EMPTY_STRING : result); }