ImgproxyUrl

Hex.pmDocs

Signed imgproxy URL generator with HMAC-SHA256 for Elixir. Zero external dependencies.

Built by Shiko — tech@shiko.vet

Installation

{:imgproxy_url, "~> 0.1"}

Configuration

config :imgproxy_url,
  host: "https://img.example.com",
  key: "your_hex_encoded_key",
  salt: "your_hex_encoded_salt"

Usage

# Basic resize
ImgproxyUrl.build("s3://bucket/photo.jpg", width: 200, height: 200)
# => "https://img.example.com/<signature>/rs:fit:200:200/q:80/<encoded>.webp"

# Custom quality and resize
ImgproxyUrl.build("s3://bucket/photo.jpg", width: 600, height: 600, quality: 90, resize: "fill")

# Plain URL encoding (human-readable source)
ImgproxyUrl.build_plain("s3://bucket/photo.jpg", width: 200, height: 200)
# => "https://img.example.com/<signature>/rs:fit:200:200/q:80/plain/s3://bucket/photo.jpg@webp"

# Override config per-call
ImgproxyUrl.build("s3://other/img.png", width: 100, height: 100, host: "https://other.img.com", key: "...", salt: "...")

Presets Pattern

defmodule MyApp.ImagePresets do
  def thumbnail(path), do: ImgproxyUrl.build(path, width: 200, height: 200, quality: 75)
  def medium(path), do: ImgproxyUrl.build(path, width: 600, height: 600, quality: 80)
  def large(path), do: ImgproxyUrl.build(path, width: 1200, height: 1200, quality: 85)
end

Links

License

MIT