Class MetadataExtractor.TiffReader

java.lang.Object
gov.nih.mipav.model.file.MetadataExtractor.TiffReader
Enclosing class:
MetadataExtractor

public class MetadataExtractor.TiffReader extends Object
Processes TIFF-formatted data, calling into client code via that MetadataExtractor.TiffHandler interface.
Author:
Drew Noakes https://drewnoakes.com
  • Constructor Details

    • TiffReader

      public TiffReader()
  • Method Details

    • processTiff

      public void processTiff(MetadataExtractor.RandomAccessReader reader, MetadataExtractor.TiffHandler handler, int tiffHeaderOffset) throws MetadataExtractor.TiffProcessingException, IOException
      Processes a TIFF data sequence.
      Parameters:
      reader - the MetadataExtractor.RandomAccessReader from which the data should be read
      handler - the MetadataExtractor.TiffHandler that will coordinate processing and accept read values
      tiffHeaderOffset - the offset within reader at which the TIFF header starts
      Throws:
      MetadataExtractor.TiffProcessingException - if an error occurred during the processing of TIFF data that could not be ignored or recovered from
      IOException - an error occurred while accessing the required data
    • processIfd

      public void processIfd(MetadataExtractor.TiffHandler handler, MetadataExtractor.RandomAccessReader reader, Set<Integer> processedIfdOffsets, int ifdOffset, int tiffHeaderOffset) throws IOException
      Processes a TIFF IFD. IFD Header:
      • 2 bytes number of tags
      Tag structure:
      • 2 bytes tag type
      • 2 bytes format code (values 1 to 12, inclusive)
      • 4 bytes component count
      • 4 bytes inline value, or offset pointer if too large to fit in four bytes
      Parameters:
      handler - the
      invalid reference
      com.drew.imaging.tiff.TiffHandler
      that will coordinate processing and accept read values
      reader - the
      invalid reference
      com.drew.lang.RandomAccessReader
      from which the data should be read
      processedIfdOffsets - the set of visited IFD offsets, to avoid revisiting the same IFD in an endless loop
      ifdOffset - the offset within reader at which the IFD data starts
      tiffHeaderOffset - the offset within reader at which the TIFF header starts
      Throws:
      IOException - an error occurred while accessing the required data
    • processTag

      private void processTag(MetadataExtractor.TiffHandler handler, int tagId, int tagValueOffset, int componentCount, int formatCode, MetadataExtractor.RandomAccessReader reader) throws IOException
      Throws:
      IOException
    • calculateTagOffset

      private int calculateTagOffset(int ifdStartOffset, int entryNumber)
      Determine the offset of a given tag within the specified IFD.
      Parameters:
      ifdStartOffset - the offset at which the IFD starts
      entryNumber - the zero-based entry number