Skip to content

Index image dimensions from IIIF info.json #654

Description

@ddeboer

Problem

Frontends need image dimensions before an image loads: layout stability (CLS, skeleton loaders with the right aspect ratio), justified/masonry galleries, correct srcset ceilings, and lightboxes such as PhotoSwipe all require the intrinsic width × height. IIIF’s size grammar (!w,h, ^, max) makes requesting images dimension-free, but layout and variant selection are irreducibly dimension-dependent – and requesting a size beyond the intrinsic one even errors on IIIF Image 3.0 servers without upscaling support.

The dimensions are available in each image’s info.json, but fetching those from the presentation layer is an N+1 problem: 20–50 extra async requests per search-results page. That lookup belongs in the data layer, at ingest time.

Context: netwerk-digitaal-erfgoed/prototypes-data-layers#14.

Proposal

Enrich indexed images with their intrinsic width and height:

  • Add optional width/height fields for image objects to the search schema and index documents. This stays within schema.org, which already defines both on MediaObject.
  • Use dimensions when the source data provides them; otherwise fetch the IIIF info.json during ingest.
  • Cache dimensions persistently, keyed by image URL: a IIIF identifier’s dimensions are immutable, so only images new to the index cost a request on re-ingest.
  • Make enrichment non-blocking: index the record without dimensions when the fetch fails (dead link, timeout), record the failure, and retry with backoff. Bound concurrency per host.

Two integers per image give consumers everything derived: aspect ratio for layout, and the size ceiling for srcset generation, zoom depth, and safe IIIF URL rewriting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions