Example usage for org.apache.commons.imaging.formats.tiff.fieldtypes FieldType ASCII

List of usage examples for org.apache.commons.imaging.formats.tiff.fieldtypes FieldType ASCII

Introduction

In this page you can find the example usage for org.apache.commons.imaging.formats.tiff.fieldtypes FieldType ASCII.

Prototype

FieldTypeAscii ASCII

To view the source code for org.apache.commons.imaging.formats.tiff.fieldtypes FieldType ASCII.

Click Source Link

Usage

From source file:com.ubb.imaging.ExifMetadataWriter.java

private void updateImageUniqueId(TiffOutputDirectory exifDirectory, String newId)
        throws IOException, ImageReadException, ImageWriteException {
    exifDirectory.removeField(TiffConstants.EXIF_TAG_IMAGE_UNIQUE_ID);

    TiffOutputField idField = new TiffOutputField(TiffConstants.EXIF_TAG_IMAGE_UNIQUE_ID, FieldType.ASCII,
            newId.getBytes("UTF-8").length, newId.getBytes("UTF-8"));

    exifDirectory.add(idField);/*from w  w  w  .  ja va 2s .  c om*/
}

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;
        }//from w  w w . ja v a2s.co 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;
}