Skip to main content

lib/phoenix_image.ex

defmodule PhoenixImage do
  @moduledoc """
  Public entry module for `phx_image`.

  This package is primarily used through `PhoenixImage.Plug`, which exposes
  an HTTP API for on-demand image transformation, and `PhoenixImage.Component`,
  a Next.js-like `<.image />` function component for Phoenix templates.

  Plug features:

  - Fetch image from absolute `http/https` source or root-relative path
  - Resize while preserving aspect ratio
  - Transcode to `webp`, `avif`, `jpg`, or `png`
  - Return long-lived cache headers

  Component features:

  - Familiar props (`src`, `alt`, `width`, `height`, `fill`, `sizes`, `quality`)
  - Auto optimizer URL and `srcset` generation
  - Optional `unoptimized` passthrough mode

  See `PhoenixImage.Plug` and `PhoenixImage.Component` for details.
  """
end