Class HeaderFormat

Object
AnchorBean<HeaderFormat>
HeaderFormat
Direct Known Subclasses:
BMP, JPEG, PNG

public abstract class HeaderFormat extends AnchorBean<HeaderFormat>
Populates ImageMetadata from the header of an image-file.

The metadata-extractor from Drew Noakes is used to read the metadata.

Author:
Owen Feehan
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract ImageFileFormat
    The associated ImageFileFormat with this header.
    Optional<ImageMetadata>
    Creates a ImageMetadata, if possible, from the metadata at path.
    protected abstract Optional<ImageMetadata>
    populateFromMetadata(com.drew.metadata.Metadata metadata, ImageFileAttributes attributes)
    Creates a ImageMetadata, if possible, from metadata.

    Methods inherited from class org.anchoranalysis.bean.AnchorBean

    checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • HeaderFormat

      public HeaderFormat()
  • Method Details

    • populateFrom

      public Optional<ImageMetadata> populateFrom(Path path) throws ImageIOException
      Creates a ImageMetadata, if possible, from the metadata at path.
      Parameters:
      path - the path to an image file.
      Returns:
      the metadata associated with path, if it was possible to infer it.
      Throws:
      ImageIOException - if the metadata does not meet expectations or I/O fails.
    • format

      protected abstract ImageFileFormat format()
      The associated ImageFileFormat with this header.

      Only files whose paths end with an extension for this format will be accepted.

      Returns:
      the format.
    • populateFromMetadata

      protected abstract Optional<ImageMetadata> populateFromMetadata(com.drew.metadata.Metadata metadata, ImageFileAttributes attributes) throws ImageIOException
      Creates a ImageMetadata, if possible, from metadata.
      Parameters:
      metadata - the Metadata to infer ImageMetadata from.
      attributes - timestamps and other file-attributes associated with the metadata.
      Returns:
      the inferred metadata, if it was possible to infer it.
      Throws:
      ImageIOException - if the metadata does not meet expectations.