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.
Problem
Frontends need image dimensions before an image loads: layout stability (CLS, skeleton loaders with the right aspect ratio), justified/masonry galleries, correct
srcsetceilings, 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
widthandheight:width/heightfields for image objects to the search schema and index documents. This stays within schema.org, which already defines both onMediaObject.info.jsonduring ingest.Two integers per image give consumers everything derived: aspect ratio for layout, and the size ceiling for
srcsetgeneration, zoom depth, and safe IIIF URL rewriting.