Image.Plug.Capabilities (image_plug v0.1.0)

Copy Markdown View Source

Probes the local libvips build for optional encoder capabilities.

Run once at application boot. Results are cached in :persistent_term so per-request reads are free.

Currently probes AVIF, JP2, and TIFF write support. Adding a probe for another capability is one new clause in probe/0 and one new accessor.

Summary

Functions

Returns whether the local libvips can encode AVIF.

Returns whether the local libvips can encode JPEG 2000 (JP2).

Performs every capability probe and caches the results.

Returns whether the local libvips can encode TIFF.

Functions

avif_write?()

@spec avif_write?() :: boolean()

Returns whether the local libvips can encode AVIF.

Falls back to a one-off probe if probe/0 (in this module) has not been called — useful in tests that exercise the encoder without booting the application.

Returns

  • true if libvips can write AVIF.

  • false otherwise.

Examples

iex> is_boolean(Image.Plug.Capabilities.avif_write?())
true

jp2_write?()

@spec jp2_write?() :: boolean()

Returns whether the local libvips can encode JPEG 2000 (JP2).

Required by IIIF Image API 3.0 Compliance Level 2 deployments that promise JP2 support. Available only when libvips was built with libopenjp2.

Returns

  • true if libvips can write JP2.

  • false otherwise.

probe()

@spec probe() :: :ok

Performs every capability probe and caches the results.

Idempotent: calling probe/0 twice in the same VM lifetime returns the same booleans without re-probing.

Returns

  • :ok.

tiff_write?()

@spec tiff_write?() :: boolean()

Returns whether the local libvips can encode TIFF.

Required by IIIF Image API 3.0 Compliance Level 2 deployments that promise TIFF support.

Returns

  • true if libvips can write TIFF.

  • false otherwise.