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

Crop operation. Extracts a sub-rectangle of the working image.

Distinct from `Image.Plug.Pipeline.Ops.Trim`, which auto-detects or
removes a border, and distinct from `Image.Plug.Pipeline.Ops.Resize`'s
fit modes, which scale-and-fit. `Crop` is an absolute extract of the
region described by `(x, y, width, height)`.

Two coordinate systems via `:units`:

* `:pixels` (default) — `x`, `y`, `width`, `height` are measured in
  pixels of the source image. `(0, 0)` is the top-left corner.

* `:percent` — all four values are floats in `0.0..100.0`,
  interpreted as percentages of the source image's dimensions. The
  interpreter resolves them against the actual source size at apply
  time, which means the same op can be reused across sources of
  different dimensions.

### Used by

* The IIIF Image API 3.0 provider's `region` URL segment, which
  accepts both `x,y,w,h` (pixels) and `pct:x,y,w,h` (percent) forms.

### Canonical order

Per `Image.Plug.Pipeline.Normaliser`, `Crop` runs after `Trim` /
`Background` and before `Resize`. The IIIF spec processes operations
in this same order — `region → size → rotation → quality → format` —
so a IIIF round-trip preserves intent.

# `t`

```elixir
@type t() :: %Image.Plug.Pipeline.Ops.Crop{
  height: number(),
  units: units(),
  width: number(),
  x: number(),
  y: number()
}
```

# `units`

```elixir
@type units() :: :pixels | :percent
```

---

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