IIIFManifestLoader

loader.graphical.IIIFManifestLoader()

Load image metadata from IIIF Presentation API manifests.

IIIF manifests contain canvas dimensions that represent image sizes. This loader extracts width/height for use with graphical timelines without needing to download or load the actual image files.

Supports both IIIF Presentation API 2.x and 3.x formats.

Examples

>>> loader = IIIFManifestLoader()
>>> loader.load("manifest.json")
>>> loader.dimensions
{'width': 4096, 'height': 299400}
>>> # Access individual canvases
>>> for canvas in loader.manifest_info.canvases:
...     print(f"{canvas.label}: {canvas.width}x{canvas.height}")

Attributes

Name Type Description
manifest_info IIIFManifestInfo Parsed manifest information (after loading).

Methods

Name Description
create_timeline Create a graphical timeline from the loaded IIIF manifest.
get_canvas Get canvas information by index.
get_metadata Get a metadata value by key.

create_timeline

loader.graphical.IIIFManifestLoader.create_timeline(
    uid=None,
    name=None,
    axis='height',
)

Create a graphical timeline from the loaded IIIF manifest.

The timeline length is determined by the image dimensions along the specified axis (height by default, for vertical piano rolls).

Parameters

Name Type Description Default
uid str | None Unique identifier for the timeline. Auto-generated if None. None
name str | None Human-readable name. Uses manifest/canvas label if None. None
axis str Which dimension to use as the timeline axis: - “height” (default): Timeline length = image height - “width”: Timeline length = image width 'height'

Returns

Name Type Description
'Timeline' A DiscreteGraphicalTimeline representing the image.

Raises

Name Type Description
RuntimeError If no manifest has been loaded.
ValueError If axis is not “height” or “width”.

Examples

>>> loader = IIIFManifestLoader()
>>> loader.load("manifest.json")
>>> timeline = loader.create_timeline(uid="dgt1_image")

get_canvas

loader.graphical.IIIFManifestLoader.get_canvas(index=0)

Get canvas information by index.

Parameters

Name Type Description Default
index int Zero-based canvas index. 0

Returns

Name Type Description
IIIFCanvasInfo IIIFCanvasInfo for the requested canvas.

Raises

Name Type Description
IndexError If index is out of range.

get_metadata

loader.graphical.IIIFManifestLoader.get_metadata(key)

Get a metadata value by key.

Parameters

Name Type Description Default
key str Metadata label to look up. required

Returns

Name Type Description
str | None Metadata value, or None if not found.