List of usage examples for org.apache.commons.imaging.formats.tiff TiffField getStringValue
public String getStringValue() throws ImageReadException
From source file:net.mozq.picto.core.ProcessCore.java
private static String getEXIFStringValue(ImageMetadata imageMetadata, TagInfo tagInfo) { TiffField field = getTiffField(imageMetadata, tagInfo); if (field == null) { return null; }/*from www . j av a 2 s . c om*/ String exifStr; try { exifStr = field.getStringValue(); } catch (ImageReadException e) { return null; } if (exifStr != null) { int nullIdx = exifStr.indexOf('\u0000'); if (nullIdx != -1) { exifStr = exifStr.substring(0, nullIdx); } } return exifStr; }
From source file:joachimeichborn.geotag.io.jpeg.PictureMetadataReader.java
private String getTagStringValue(final TagInfo aTagInfo) { if (jpegMetadata != null) { final TiffField field = jpegMetadata.findEXIFValueWithExactMatch(aTagInfo); if (field == null) { logger.fine("Field " + aTagInfo + " is null for picture " + pictureFile); return null; }/* www.j a va 2 s . c o m*/ final FieldType fieldType = field.getFieldType(); if (fieldType.getType() == FieldType.ASCII.getType()) { try { return field.getStringValue(); } catch (ImageReadException e) { logger.fine("Failed to read " + aTagInfo + " from " + pictureFile + ": " + e.getMessage()); } } } return null; }
From source file:net.tourbook.photo.Photo.java
/** * Date/Time/*from w ww . j a v a 2 s .co m*/ * * @param jpegMetadata * @param file * @return */ private LocalDateTime getExifValueDate(final JpegImageMetadata jpegMetadata) { // /* // * !!! time is not correct, maybe it is the time when the GPS signal was // * received !!! // */ // printTagValue(jpegMetadata, TiffConstants.GPS_TAG_GPS_TIME_STAMP); try { final TiffField exifDate = jpegMetadata.findEXIFValueWithExactMatch(// ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); if (exifDate != null) { return LocalDateTime.parse(exifDate.getStringValue(), _dtParser); } final TiffField tiffDate = jpegMetadata .findEXIFValueWithExactMatch(TiffTagConstants.TIFF_TAG_DATE_TIME); if (tiffDate != null) { return LocalDateTime.parse(tiffDate.getStringValue(), _dtParser); } } catch (final Exception e) { // ignore } return null; }
From source file:net.tourbook.photo.Photo.java
private String getExifValueString(final JpegImageMetadata jpegMetadata, final TagInfo tagInfo) { try {//w w w .j a v a 2 s.co m final TiffField field = jpegMetadata.findEXIFValueWithExactMatch(tagInfo); if (field != null) { return field.getStringValue(); } } catch (final Exception e) { // ignore } return null; }
From source file:net.tourbook.photo.Photo.java
private LocalDateTime getTiffValueDate(final TiffImageMetadata tiffMetadata) { try {//from w ww .j av a 2 s . co m final TiffField exifDate = tiffMetadata.findField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL, true); if (exifDate != null) { return LocalDateTime.parse(exifDate.getStringValue(), _dtParser); } final TiffField date = tiffMetadata.findField(TiffTagConstants.TIFF_TAG_DATE_TIME, true); if (date != null) { return LocalDateTime.parse(date.getStringValue(), _dtParser); } } catch (final Exception e) { // ignore } return null; }
From source file:net.tourbook.photo.Photo.java
private String getTiffValueString(final TiffImageMetadata tiffMetadata, final TagInfo tagInfo) { try {/*from ww w . j a v a2 s. c o m*/ final TiffField field = tiffMetadata.findField(tagInfo, true); if (field != null) { return field.getStringValue(); } } catch (final Exception e) { // ignore } return null; }
From source file:zz.filecollector.fileprocessor.JpgPhotoProcessor.java
@Override public void extractFileInfo(File file, FileInfo info) { FileProcessor.getBasicFileInfo(file, info); if (info.getFileType() == FileInfo.UNKNOWN) { info.setFileType(FileInfo.PHOTO); }// ww w . j a v a 2 s . co m try { ImageMetadata metadata = Imaging.getMetadata(file); if (metadata instanceof JpegImageMetadata) { final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; if (info.getCreateDate() == null) { try { TiffField dateTime = jpegMetadata .findEXIFValueWithExactMatch(TiffTagConstants.TIFF_TAG_DATE_TIME); if (dateTime != null) { String str = dateTime.getStringValue(); // 2014:02:06 12:11:26 if (StringUtils.isNotEmpty(str)) { Date date = dateFormat.parse(str); info.setCreateDate(date); } } } catch (Exception e) { e.printStackTrace(); } } if (info.getDevice() == null) { TiffField model = jpegMetadata.findEXIFValueWithExactMatch(TiffTagConstants.TIFF_TAG_MODEL); if (model != null) { byte[] bytes = model.getByteArrayValue(); String modelStr = new String(bytes).trim(); if (StringUtils.isNotEmpty(modelStr)) { info.setDevice(modelStr); } } } } } catch (Exception ex) { ex.printStackTrace(); } }