Class Info
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
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static final class
Represents an embedded subimage within a container stream.static enum
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Info.Builder
builder()
boolean
N.B.: theserialization timestamp
is not considered.static Info
fromJSON
(InputStream jsonStream) static Info
static Info
For convenient serialization.getMetadata
(int imageIndex) int
Returns the number of "pages" contained in the image.int
Returns the number of resolutions contained in the image.N.B.: Although it would be possible for mostInfoCache
s 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.getSize()
getSize
(int imageIndex) int
hashCode()
void
setIdentifier
(Identifier identifier) void
setMediaType
(MediaType mediaType) For convenient deserialization.void
setNumResolutions
(int numResolutions) void
setSerializationTimestamp
(Instant timestamp) void
setSourceFormat
(Format sourceFormat) toJSON()
toString()
void
-
Constructor Details
-
Info
public Info()
-
-
Method Details
-
builder
-
fromJSON
- Throws:
IOException
-
fromJSON
- Throws:
IOException
-
fromJSON
- Throws:
IOException
-
equals
N.B.: theserialization timestamp
is not considered. -
getApplicationVersion
- Returns:
- Version of the application with which the instance was or will be serialized.
- See Also:
-
getIdentifier
- Returns:
- Image identifier.
-
getImages
-
getMediaType
-
getMetadata
-
getMetadata
-
getNumPages
public int getNumPages()Returns the number of "pages" contained in the image. If theimages
appear to comprise a pyramid, this is1
. 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.
- For formats like multi-resolution TIFF, this will match the size
of
-
getSerialization
- See Also:
-
getSerializationTimestamp
N.B.: Although it would be possible for mostInfoCache
s 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
- Returns:
- Size of the main image.
-
getSize
- Returns:
- Size of the image at the given index.
-
getSourceFormat
- Returns:
- Source format of the image, or
Format.UNKNOWN
if unknown.
-
hashCode
-
setIdentifier
- Parameters:
identifier
- Identifier of the image described by the instance.
-
setMediaType
-
setNumResolutions
public void setNumResolutions(int numResolutions) - Parameters:
numResolutions
- Number of resolutions contained in the image.
-
setSerializationTimestamp
- Parameters:
timestamp
- Time at which the instance is serialized.
-
setSourceFormat
-
toJSON
- Returns:
- JSON representation of the instance.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
toString
-
writeAsJSON
- Parameters:
os
- Output stream to write to.- Throws:
IOException
-