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

Copy Markdown View Source

Parses the four IIIF Image API 3.0 option segments (region / size / rotation / quality.format) into a canonical Image.Plug.Pipeline.

Inverse of Image.Components.URL.iiif/2. Targets Compliance Level 2 of the Image API 3.0 specification.

Built incrementally over Phases 3b–3d:

  • 3b — region: full | square | <x,y,w,h> | pct:<x,y,w,h>.

  • 3c — size: max | ^max | <w>, | ,<h> | <w>,<h> | !<w>,<h> | pct:<n> plus ^ upscale prefixes.

  • 3d — rotation, quality, format.

Summary

Functions

Parses the four IIIF option segments into a Pipeline.

Functions

parse(arg, parser_options \\ [])

@spec parse(
  {String.t(), String.t(), String.t(), String.t()},
  keyword()
) :: {:ok, Image.Plug.Pipeline.t()} | {:error, Image.Plug.Error.t()}

Parses the four IIIF option segments into a Pipeline.

Arguments

  • segments is a {region, size, rotation, quality_dot_format} four-tuple of strings, exactly as produced by Image.Plug.Provider.IIIF.URL.parse/2.

  • parser_options is a keyword list. :strict? (default true) rejects malformed segments; with :strict? set to false, unrecognised segments are reported with Logger.warning/1 and treated as their respective no-op (full / max / 0 / default).

Returns

  • {:ok, pipeline} on success.

  • {:error, %Image.Plug.Error{}} on the first malformed segment.