IIIFImagePlug.V3.Options (IIIFImagePlug v0.7.0)

View Source

A struct for setting IIIFImagePlug.V3 plug options.

The plug relies on Vix package for the image processing, which includes a precompiled libvips binary out of the box (Linux/MacOS). The possible values for :preferred_formats and :extra_formats thus are currently as follows: [:jpg, :png, :webp, :tif, :gif, :raw, :vips].

You can configure Vix to use your own installation of libvips if you need other formats, see the Vix documentation, then add the format suffix to one of the options.

Options

:max_width (default: 10000)

The maximum image width the plug will serve.

:max_height (default: 10000)

The maximum image height the plug will serve.

:max_area (default: 100000000)

The maximum amount of image pixels the plug will serve (does not necessarily have to be max_width * max_height).

:preferred_formats (default: [:jpg])

The preferred formats to be used for your plug.

:extra_formats (default: [:webp, :png])

The extra formats your plug can deliver.

:format_options (default: %{})

Add custom libvips options to be used when creating the response images. Whatever you define here is passed directly to Vix and not sanity checked again by the plug:

%Options{
  format_options: %{
    jpg: [Q: 5, background: [255, 255, 0]],
    webp: [lossless: true],
    png: [bitdepth: 1]
  }
}

For possible values check out Vix' (...)save functions for the different output formats.

:temp_dir (default: uses System.tmp_dir!/0)

To be more precise, the default evaluates System.tmp_dir!/0 and creates a directory "iiif_image_plug" there.

Because of how the TIF, raw and vips file formats are structured, the plug can not stream those when they are requested as the response format. Instead, the result image gets written to a temporary file, which is then streamed from disk and getting deleted afterwards.

If you want to forgo this file creation, you can set this option to :buffer instead of a file path. This will configure the plug to write the complete image to memory instead of disk - which is faster but also may cause memory issues if very large images are requested.

Summary

Types

t()

@type t() :: %IIIFImagePlug.V3.Options{
  extra_formats: list(),
  format_options: map(),
  max_area: integer(),
  max_height: integer(),
  max_width: integer(),
  preferred_formats: list(),
  temp_dir: String.t() | atom()
}