Class InferFromHeader


public class InferFromHeader extends ImageMetadataReader
Tries to construct the ImageMetadata from EXIF and other metadata, if available, or otherwise falls back to another reader.

It supports a limited number of file-types, as identified by an extension in the path. By default, it supports:

  • JPEG (.jpg or .jpeg)
  • PNG (.png)
Author:
Owen Feehan
  • Constructor Details

    • InferFromHeader

      public InferFromHeader()
    • InferFromHeader

      public InferFromHeader(ImageMetadataReader fallback, List<HeaderFormat> formats)
      Creates a new InferFromHeader instance.
      Parameters:
      fallback - Fallback to use if EXIF information is non-existing or absent.
      formats - The formats whose headers will be searched, to find sufficient metadata to populate ImageMetadata.
  • Method Details

    • openFile

      public ImageMetadata openFile(Path path, StackReader defaultStackReader, OperationContext context) throws ImageIOException
      Description copied from class: ImageMetadataReader
      Opens a file containing one or more images but does not read an image.
      Specified by:
      openFile in class ImageMetadataReader
      Parameters:
      path - where the file is located.
      defaultStackReader - the default StackReader to use, if needed, and if not otherwise specified, for reading metadata.
      context - context for reading a stack from the file-system.
      Returns:
      an interface to the opened file that should be closed when no longer in use.
      Throws:
      ImageIOException - if the file cannot be read.
    • getFallback

      public ImageMetadataReader getFallback()
      Fallback to use if EXIF information is non-existing or absent.
    • setFallback

      public void setFallback(ImageMetadataReader fallback)
      Fallback to use if EXIF information is non-existing or absent.
    • getFormats

      public List<HeaderFormat> getFormats()
      The formats whose headers will be searched, to find sufficient metadata to populate ImageMetadata.
    • setFormats

      public void setFormats(List<HeaderFormat> formats)
      The formats whose headers will be searched, to find sufficient metadata to populate ImageMetadata.