Rindle.Processor.Image (Rindle v0.1.5)

Copy Markdown View Source

Image processor adapter using the Image library (powered by libvips/Vix).

This is Rindle's bundled reference processor — symmetric with Rindle.Storage.S3 and Rindle.Storage.Local for the Rindle.Storage behaviour. Adopters can swap in a custom processor by implementing Rindle.Processor and configuring the profile's :processor option, but most use cases are well-served by this adapter.

Recognized variant_spec keys

The variant_spec map passed to process/3 recognizes these keys:

  • :width — target width in pixels (pos_integer())
  • :height — target height in pixels (pos_integer())
  • :mode — resize strategy, one of :fit, :crop, :fill (default: :fit)
  • :format — output format, one of :jpg, :png, :webp, or a string extension. When omitted, format is inferred from destination_path's extension.
  • :quality — output quality, 1..100 (default: 80)

Supported modes

  • :fit — resize the image to fit within :width x :height, preserving aspect ratio
  • :crop — crop the image to exactly :width x :height, centered
  • :fill — like :crop but optimized for filling the target dimensions

Format inference

When :format is omitted from variant_spec, the adapter infers the format from destination_path's file extension via Path.extname/1. Recognized extensions: .jpg / .jpeg -> JPEG, .png -> PNG, .webp -> WebP. Unknown extensions fall back to libvips's default for the file extension.