imgproxy v1.0.0 Imgproxy View Source
Documentation for the Imgproxy package, an Elixir library that helps generate urls for use with an imgproxy server.
For usage information, see the documentation, which includes guides, API information for important modules, and links to useful resources.
Link to this section Summary
Functions
Generate a path to an image based on the given image url and image options.
Generate an imgproxy URL. The first argument is the URL for the image, followed by optional parameters.
Generate an imgproxy URL. The first argument is the URL for the image, followed by width and height. All other parameters are generated using defaults.
Link to this section Types
Specs
Link to this section Functions
Specs
build_path(img_url :: String.t(), opts :: image_opts()) :: String.t()
Generate a path to an image based on the given image url and image options.
This is the path to the image after the signature, so the result of this call should be
appended to the imgproxy's url and signature value to create the final image path. This is
public because it can be used directly if you don't need a signature. The optional parameters
are the same as for url/2
. For instance:
Examples
iex> partial_path = Imgproxy.build_path("https://placekitten.com/200/300")
iex> "https://imgcdn.example.com" <> "/insecure" <> partial_path
"https://imgcdn.example.com/insecure/fill/300/300/sm/1/aHR0cHM6Ly9wbGFjZWtpdHRlbi5jb20vMjAwLzMwMA"
Specs
url(img_url :: String.t(), opts :: image_opts()) :: String.t()
Generate an imgproxy URL. The first argument is the URL for the image, followed by optional parameters.
Those parameters and their defaults are:
- resize: default, "fill"
- width: default, 300
- height: default, 300
- gravity: default, "sm" for "smart"
- enlarge: default, "1" for enlarge if necessary
- extension: default, empty, so attempt to preserve the original image type
Examples
iex> Imgproxy.url("https://placekitten.com/200/300")
"https://imgcdn.example.com/insecure/fill/300/300/sm/1/aHR0cHM6Ly9wbGFjZWtpdHRlbi5jb20vMjAwLzMwMA"
iex> Imgproxy.url("https://placekitten.com/200/300",
...> resize: "fill",
...> width: 123,
...> height: 321,
...> gravity: "sm",
...> enlarge: "1",
...> extension: "jpg")
"https://imgcdn.example.com/insecure/fill/123/321/sm/1/aHR0cHM6Ly9wbGFjZWtpdHRlbi5jb20vMjAwLzMwMA.jpg"
Specs
Generate an imgproxy URL. The first argument is the URL for the image, followed by width and height. All other parameters are generated using defaults.
Examples
iex> Imgproxy.url("https://placekitten.com/200/300", 100, 150)
"https://imgcdn.example.com/insecure/fill/100/150/sm/1/aHR0cHM6Ly9wbGFjZWtpdHRlbi5jb20vMjAwLzMwMA"