Build Status Hex pm API Docs

Imgproxy is an Elixir library that helps generate imgproxy URLs. Before using this library, you should have a running imgproxy server.

Note: As of version 3.0, OTP >= 22.1 and imgproxy >= 2.0.0 are required.


To install Imgproxy, just add an entry to your mix.exs:

def deps do
    {:imgproxy, "~> 3.0"}

(Check Hex to make sure you're using an up-to-date version number.)


In your config/config.exs you can set a few options:

config :imgproxy,
  prefix: "",
  key: "cdf104fc78b7d7f6f0158c253612f5dsecretsecret...",
  salt: "aad7034f611b7fc28c6d344f72ea19secretsecret..."

The prefix should be the location of the imgproxy server. key and salt are only necessary if you are using URL signatures. To generate the key a key and salt, you can use:

$> mix imgproxy.gen.secret

You can use the output as your key or salt (ideally, just run the command twice, use the first output for your key and the second output for your salt).


Usage is simple - first generate an Imgproxy struct via, add any options you'd like, then convert to a string.


# Generate URL for an image, using defaults"") |> to_string()

# Resize to 123x321
|> Imgproxy.resize(123, 321, type: "fill")
|> to_string()

# Crop and return a jpg
|> Imgproxy.crop(100, 100)
|> Imgproxy.set_extension("jpg")
|> to_string()

Running Tests

To run tests:

$> mix test

Reporting Issues

Please report all issues on github.