PhxMediaLibrary.Conversion (PhxMediaLibrary v0.6.1)

Copy Markdown View Source

Represents an image conversion configuration.

Conversions define how to transform images (resize, crop, etc.) and can be limited to specific collections.

Summary

Functions

Create a new conversion configuration.

Types

fit()

@type fit() :: :contain | :cover | :fill | :crop

format()

@type format() :: :jpg | :png | :webp | :original

t()

@type t() :: %PhxMediaLibrary.Conversion{
  collections: [atom()],
  fit: fit(),
  format: format() | nil,
  height: pos_integer() | nil,
  name: atom(),
  quality: 1..100 | nil,
  queued: boolean(),
  width: pos_integer() | nil
}

Functions

new(name, opts)

@spec new(
  atom(),
  keyword()
) :: t()

Create a new conversion configuration.

Options

  • :width - Target width in pixels
  • :height - Target height in pixels
  • :fit - Resize strategy (:contain, :cover, :fill, :crop)
  • :quality - Output quality for JPEG/WebP (1-100)
  • :format - Output format (:jpg, :png, :webp, :original)
  • :collections - Only apply to these collections (default: all)
  • :queued - Process asynchronously (default: true)