The canonical, provider-neutral image-processing pipeline.
A pipeline is an ordered list of typed operation structs (under
Image.Plug.Pipeline.Ops.*) plus pipeline-wide settings: the
output format, an error policy, and a debug breadcrumb identifying
the provider that produced it.
Pipelines are pure data. Behaviour lives in
Image.Plug.Pipeline.Interpreter (executes ops),
Image.Plug.Pipeline.Encoder (serialises the result), and
Image.Plug.Pipeline.Normaliser (reorders, folds, validates).
Summary
Functions
Appends an operation to a pipeline.
Builds a new, empty pipeline.
Replaces the pipeline's output (Ops.Format) struct.
Types
@type on_error() ::
:auto
| :render_error_image
| :fallback_to_source
| :raise
| {:status, 100..599}
@type op() :: Image.Plug.Pipeline.Ops.Rotate.t() | Image.Plug.Pipeline.Ops.Trim.t() | Image.Plug.Pipeline.Ops.Flip.t() | Image.Plug.Pipeline.Ops.Resize.t() | Image.Plug.Pipeline.Ops.Background.t() | Image.Plug.Pipeline.Ops.Adjust.t() | Image.Plug.Pipeline.Ops.Sharpen.t() | Image.Plug.Pipeline.Ops.Blur.t() | Image.Plug.Pipeline.Ops.Border.t() | Image.Plug.Pipeline.Ops.Draw.t() | Image.Plug.Pipeline.Ops.Segment.t()
@type t() :: %Image.Plug.Pipeline{ on_error: on_error(), ops: [op()], output: Image.Plug.Pipeline.Ops.Format.t(), provider: nil | module() }
Functions
Appends an operation to a pipeline.
Arguments
pipelineis anImage.Plug.Pipelinestruct.opis any operation struct underImage.Plug.Pipeline.Ops.*.
Returns
- The pipeline with
opappended to:ops.
Examples
iex> alias Image.Plug.Pipeline
iex> alias Image.Plug.Pipeline.Ops.Rotate
iex> p = Pipeline.append(Pipeline.new(), %Rotate{angle: 90})
iex> length(p.ops)
1
Builds a new, empty pipeline.
Options
:outputis anImage.Plug.Pipeline.Ops.Formatstruct describing the encoder configuration. Defaults to%Ops.Format{}(auto format, quality 85, copyright-only metadata).:on_erroris the error policy. Defaults to:auto— seeImage.Plugfor selection semantics.:provideris an optional debug breadcrumb identifying the provider module that produced the pipeline.
Returns
- An empty
Image.Plug.Pipelinestruct.
Examples
iex> p = Image.Plug.Pipeline.new()
iex> p.ops
[]
iex> p.output.type
:auto
@spec put_output(t(), Image.Plug.Pipeline.Ops.Format.t()) :: t()
Replaces the pipeline's output (Ops.Format) struct.
Arguments
pipelineis anImage.Plug.Pipelinestruct.formatis anImage.Plug.Pipeline.Ops.Formatstruct.
Returns
- The pipeline with
:outputreplaced.
Examples
iex> alias Image.Plug.Pipeline
iex> alias Image.Plug.Pipeline.Ops.Format
iex> p = Pipeline.put_output(Pipeline.new(), %Format{type: :webp, quality: 80})
iex> p.output.type
:webp