# `PhoenixImage.Plug`
[🔗](https://gitlab.com/clschnei/phoenix_image/blob/v0.1.0/lib/phoenix_image/plug.ex#L1)

HTTP contract for on-demand image optimization.

## Plug Options

- `:cache_control` - response cache header
  (default: `"public, max-age=31536000, immutable"`).
- `:allowed_hosts` - list of additional hosts allowed for absolute `src`
  values. Same-host requests are always allowed.

## Query Params

- `src` (required): absolute `http/https` URL or root-relative path.
- `w` (optional): positive integer width, max `8192`.
- `h` (optional): positive integer height, max `8192`.
- `q` (optional): quality in `1..100`.
- `f` (optional): `webp|avif|jpg|png`, defaults to `webp`.
- `upscale` (optional): `true|false`, defaults to `false`.

## Responses

- `200` with optimized binary body.
  May include `x-phoenix-image-upscale: skipped` when enlargement was clamped.
- `400` invalid parameters.
- `403` disallowed source host.
- `404` source not found upstream.
- `500` upstream or processing error.

---

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