PhxMediaLibrary.ImageProcessor behaviour (PhxMediaLibrary v0.6.1)

Copy Markdown View Source

Behaviour for image processing adapters.

The default implementation uses the Image library (libvips).

Summary

Callbacks

Apply a conversion to an image.

Get image dimensions.

Open an image from a file path.

Save an image to a file path. Returns the image for chaining.

Generate a tiny placeholder (base64 encoded).

Types

image()

@type image() :: any()

Callbacks

apply_conversion(image, t)

@callback apply_conversion(image(), PhxMediaLibrary.Conversion.t()) ::
  {:ok, image()} | {:error, term()}

Apply a conversion to an image.

dimensions(image)

@callback dimensions(image()) ::
  {:ok, {width :: integer(), height :: integer()}} | {:error, term()}

Get image dimensions.

open(path)

@callback open(path :: String.t()) :: {:ok, image()} | {:error, term()}

Open an image from a file path.

save(image, path, opts)

@callback save(image(), path :: String.t(), opts :: keyword()) ::
  {:ok, image()} | {:error, term()}

Save an image to a file path. Returns the image for chaining.

tiny_placeholder(image)

@callback tiny_placeholder(image()) :: {:ok, String.t()} | {:error, term()}

Generate a tiny placeholder (base64 encoded).