Example usage for org.apache.commons.imaging ImagingConstants PARAM_KEY_READ_THUMBNAILS

List of usage examples for org.apache.commons.imaging ImagingConstants PARAM_KEY_READ_THUMBNAILS

Introduction

In this page you can find the example usage for org.apache.commons.imaging ImagingConstants PARAM_KEY_READ_THUMBNAILS.

Prototype

String PARAM_KEY_READ_THUMBNAILS

To view the source code for org.apache.commons.imaging ImagingConstants PARAM_KEY_READ_THUMBNAILS.

Click Source Link

Document

Parameter key.

Usage

From source file:net.tourbook.photo.Photo.java

/**
 * Updated metadata from the image file/* w  w w  .ja va  2s. c o  m*/
 * 
 * @param isReadThumbnail
 * @return Returns image metadata <b>with</b> image thumbnail <b>only</b> when
 *         <code>isReadThumbnail</code> is <code>true</code>, otherwise it checks if metadata
 *         are already loaded.
 */
public IImageMetadata getImageMetaData(final Boolean isReadThumbnail) {

    if (_photoImageMetadata != null && isReadThumbnail == false) {

        // meta data are available but the exif thumnail is not requested

        return null;
    }

    if (PhotoLoadManager.isImageLoadingError(imageFilePathName)) {
        // image could not be loaded previously
        return null;
    }

    IImageMetadata imageFileMetadata = null;

    try {

        /*
         * read metadata WITH thumbnail image info, this is the default when the pamameter is
         * ommitted
         */
        final HashMap<String, Object> params = new HashMap<String, Object>();
        params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, isReadThumbnail);

        //         final long start = System.currentTimeMillis();

        imageFileMetadata = Imaging.getMetadata(imageFile, params);

        //         System.out.println(UI.timeStamp()
        //               + Thread.currentThread().getName()
        //               + "read exif\t"
        //               + ((System.currentTimeMillis() - start) + " ms")
        //               + ("\tWithThumb: " + isReadThumbnail)
        //               + ("\t" + imageFilePathName)
        //         //
        //               );
        //         // TODO remove SYSTEM.OUT.PRINTLN
        //
        //         System.out.println(imageFileMetadata);
        //         // TODO remove SYSTEM.OUT.PRINTLN

    } catch (final Exception e) {

        StatusUtil.log(NLS.bind(//
                "Could not read metadata from image \"{0}\"", //$NON-NLS-1$
                imageFile));

        PhotoLoadManager.putPhotoInLoadingErrorMap(imageFilePathName);

    } finally {

        final PhotoImageMetadata photoImageMetadata = createPhotoMetadata(imageFileMetadata);

        updateImageMetadata(photoImageMetadata);
    }

    return imageFileMetadata;
}