Image.Plug.Pipeline.Ops.Resize (image_plug v0.1.0)

Copy Markdown View Source

Resize operation. Combines target dimensions, fit mode, gravity (focal point for cropping), upscale policy, and DPR (device pixel ratio).

Either :width, :height, or both may be set. When only one is set, the other is inferred from the source aspect ratio per the chosen :fit mode.

:width may also be the atom :auto, mirroring Cloudflare's client-hint-driven sizing. The interpreter resolves it to a concrete pixel count from request hints; if no hint is available it falls back to the source width.

Summary

Types

fit()

@type fit() :: :contain | :cover | :crop | :pad | :scale_down | :squeeze

gravity()

@type gravity() ::
  :auto
  | :face
  | :center
  | :north
  | :south
  | :east
  | :west
  | :north_east
  | :north_west
  | :south_east
  | :south_west
  | {:xy, float(), float()}

t()

@type t() :: %Image.Plug.Pipeline.Ops.Resize{
  dpr: pos_integer(),
  face_zoom: float(),
  fit: fit(),
  gravity: gravity(),
  height: nil | pos_integer(),
  size_pct: nil | number(),
  upscale?: boolean(),
  width: nil | :auto | pos_integer()
}