Image.Plug.Provider.IIIF.InfoJson (image_plug v0.1.0)

Copy Markdown View Source

Builds the IIIF Image API 3.0 Image Information document (info.json) for a given source.

The info document describes what the server can do with this particular image: its full pixel dimensions, the qualities and formats it can deliver, the spec features it supports, and the compliance level. Clients fetch info.json before issuing any image request to learn what URLs they're allowed to construct.

This module is invoked by Image.Plug when an IIIF provider recognises an info.json request. The provider tags the request with :json output; the plug routes to build/2 instead of the normal pipeline interpreter.

Compliance

Targets IIIF Image API 3.0 Compliance Level 2. The advertised extraFeatures, extraQualities, and extraFormats reflect what Image.Plug.Provider.IIIF.Options can parse and what Image.Plug.Capabilities confirms libvips can encode.

Summary

Functions

Builds an info.json map for the given source dimensions.

Functions

build(id, arg)

@spec build(
  String.t(),
  {pos_integer(), pos_integer()}
) :: map()

Builds an info.json map for the given source dimensions.

Arguments

  • id is the absolute URL the info.json document is served from without the trailing /info.json segment. Per the spec, this is the image's canonical identifier URL.

  • dimensions is {width, height} of the source image, in pixels.

Returns

Examples

iex> info = Image.Plug.Provider.IIIF.InfoJson.build(
...>   "https://iiif.example.org/iiif/3/cat.jpg",
...>   {1024, 768}
...> )
iex> info["@context"]
"http://iiif.io/api/image/3/context.json"
iex> info["width"]
1024
iex> info["height"]
768
iex> info["protocol"]
"http://iiif.io/api/image"