# `Image.Plug.Pipeline`
[🔗](https://github.com/elixir-image/image_plug/blob/v0.1.0/lib/image/plug/pipeline.ex#L1)

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).

# `on_error`

```elixir
@type on_error() ::
  :auto
  | :render_error_image
  | :fallback_to_source
  | :raise
  | {:status, 100..599}
```

# `op`

```elixir
@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()
```

# `t`

```elixir
@type t() :: %Image.Plug.Pipeline{
  on_error: on_error(),
  ops: [op()],
  output: Image.Plug.Pipeline.Ops.Format.t(),
  provider: nil | module()
}
```

# `append`

```elixir
@spec append(t(), op()) :: t()
```

Appends an operation to a pipeline.

### Arguments

* `pipeline` is an `Image.Plug.Pipeline` struct.

* `op` is any operation struct under `Image.Plug.Pipeline.Ops.*`.

### Returns

* The pipeline with `op` appended 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

# `new`

```elixir
@spec new(keyword()) :: t()
```

Builds a new, empty pipeline.

### Options

* `:output` is an `Image.Plug.Pipeline.Ops.Format` struct describing
  the encoder configuration. Defaults to `%Ops.Format{}` (auto format,
  quality 85, copyright-only metadata).

* `:on_error` is the error policy. Defaults to `:auto` — see
  `Image.Plug` for selection semantics.

* `:provider` is an optional debug breadcrumb identifying the provider
  module that produced the pipeline.

### Returns

* An empty `Image.Plug.Pipeline` struct.

### Examples

    iex> p = Image.Plug.Pipeline.new()
    iex> p.ops
    []
    iex> p.output.type
    :auto

# `put_output`

```elixir
@spec put_output(t(), Image.Plug.Pipeline.Ops.Format.t()) :: t()
```

Replaces the pipeline's output (`Ops.Format`) struct.

### Arguments

* `pipeline` is an `Image.Plug.Pipeline` struct.

* `format` is an `Image.Plug.Pipeline.Ops.Format` struct.

### Returns

* The pipeline with `:output` replaced.

### 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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
