Class HeaderFormat

Object
org.anchoranalysis.bean.AnchorBean<HeaderFormat>
org.anchoranalysis.plugin.io.bean.metadata.header.HeaderFormat
Direct Known Subclasses:
BMP, JPEG, PNG

public abstract class HeaderFormat
extends org.anchoranalysis.bean.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
    HeaderFormat()  
  • Method Summary

    Modifier and Type Method Description
    protected abstract org.anchoranalysis.core.format.ImageFileFormat format()
    The associated ImageFileFormat with this header.
    Optional<org.anchoranalysis.image.core.stack.ImageMetadata> populateFrom​(Path path)
    Creates a ImageMetadata, if possible, from the metadata at path.
    protected abstract Optional<org.anchoranalysis.image.core.stack.ImageMetadata> populateFromMetadata​(com.drew.metadata.Metadata metadata, org.anchoranalysis.image.core.stack.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

  • Method Details

    • populateFrom

      public Optional<org.anchoranalysis.image.core.stack.ImageMetadata> populateFrom​(Path path) throws org.anchoranalysis.image.io.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:
      org.anchoranalysis.image.io.ImageIOException - if the metadata does not meet expectations or I/O fails.
    • format

      protected abstract org.anchoranalysis.core.format.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<org.anchoranalysis.image.core.stack.ImageMetadata> populateFromMetadata​(com.drew.metadata.Metadata metadata, org.anchoranalysis.image.core.stack.ImageFileAttributes attributes) throws org.anchoranalysis.image.io.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:
      org.anchoranalysis.image.io.ImageIOException - if the metadata does not meet expectations.