Class Info

java.lang.Object
is.galia.image.Info

public final class Info extends Object

Contains JSON-serializable information about an image file, including its format, dimensions, embedded metadata, subimages, and tile sizes— essentially a superset of characteristics of all formats supported by the application.

Instances are format-, codec-, and endpoint-agnostic.

All sizes are raw pixel data sizes, disregarding orientation.

The current class design supports multiple physical subimages, but not nested ones. The first subimage is considered the primary image and additional images are siblings. "Child" images are not supported.

Instances ultimately originate from InfoReader, but subsequently they can be cached in an InfoCache and/or a HeapInfoCache, perhaps for a very long time. When an instance is needed, it may be preferentially acquired from a cache, with an InfoReader being consulted only as a last resort (see CacheFacade.fetchOrReadInfo(Identifier, Format, Decoder)). As a result, changes to the class definition must be implemented carefully so that older serializations remain readable. (Otherwise, users might have to purge their InfoCache whenever the class changes.)

History

See Info.Serialization.

  • Constructor Details

    • Info

      public Info()
  • Method Details

    • builder

      public static Info.Builder builder()
    • fromJSON

      public static Info fromJSON(Path jsonFile) throws IOException
      Throws:
      IOException
    • fromJSON

      public static Info fromJSON(InputStream jsonStream) throws IOException
      Throws:
      IOException
    • fromJSON

      public static Info fromJSON(String json) throws IOException
      Throws:
      IOException
    • equals

      public boolean equals(Object obj)
      N.B.: the serialization timestamp is not considered.
      Overrides:
      equals in class Object
    • getApplicationVersion

      public SoftwareVersion getApplicationVersion()
      Returns:
      Version of the application with which the instance was or will be serialized.
      See Also:
    • getIdentifier

      public Identifier getIdentifier()
      Returns:
      Image identifier.
    • getImages

      public List<Info.Image> getImages()
    • getMediaType

      public MediaType getMediaType()
      For convenient serialization.
      See Also:
    • getMetadata

      public Metadata getMetadata()
    • getMetadata

      public Metadata getMetadata(int imageIndex)
    • getNumPages

      public int getNumPages()
      Returns the number of "pages" contained in the image. If the images appear to comprise a pyramid, this is 1. Otherwise, it is equal to their count.
      Returns:
      Page count.
    • getNumResolutions

      public int getNumResolutions()

      Returns the number of resolutions contained in the image.

      • For formats like multi-resolution TIFF, this will match the size of getImages().
      • For formats like JPEG2000, it will be (number of decomposition levels) + 1.
      • For more conventional formats like JPEG, PNG, BMP, etc., it will be 1.
      Returns:
      Number of resolutions contained in the image.
    • getSerialization

      public Info.Serialization getSerialization()
      See Also:
    • getSerializationTimestamp

      public Instant getSerializationTimestamp()
      N.B.: Although it would be possible for most InfoCaches to obtain a serialization timestamp by other means, such as e.g. filesystem attributes, storing it within the serialized instance makes a separate I/O call unnecessary.
      Returns:
      Timestamp that the instance was serialized.
    • getSize

      public Size getSize()
      Returns:
      Size of the main image.
    • getSize

      public Size getSize(int imageIndex)
      Returns:
      Size of the image at the given index.
    • getSourceFormat

      public Format getSourceFormat()
      Returns:
      Source format of the image, or Format.UNKNOWN if unknown.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • setIdentifier

      public void setIdentifier(Identifier identifier)
      Parameters:
      identifier - Identifier of the image described by the instance.
    • setMediaType

      public void setMediaType(MediaType mediaType)
      For convenient deserialization.
      See Also:
    • setNumResolutions

      public void setNumResolutions(int numResolutions)
      Parameters:
      numResolutions - Number of resolutions contained in the image.
    • setSerializationTimestamp

      public void setSerializationTimestamp(Instant timestamp)
      Parameters:
      timestamp - Time at which the instance is serialized.
    • setSourceFormat

      public void setSourceFormat(Format sourceFormat)
    • toJSON

      public String toJSON() throws com.fasterxml.jackson.core.JsonProcessingException
      Returns:
      JSON representation of the instance.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeAsJSON

      public void writeAsJSON(OutputStream os) throws IOException
      Parameters:
      os - Output stream to write to.
      Throws:
      IOException