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 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.