View Source Imgproxy (imgproxy v3.0.2)
Summary
Types
A number of pixels to be used as a dimension.
Provide type and enlarge configuration arguments to a resize option.
Functions
Add a formatting option to the Imgproxy.t/0
.
Crop an image to the given width and height.
Generate a new Imgproxy.t/0
struct for the given image source URL to fetch the
Info Endpoint.
Generate a new Imgproxy.t/0
struct for the given image source URL.
Resize an image to the given width and height.
Set the file extension (which will produce an image of that type).
Set the gravity option.
Generate an imgproxy URL.
Types
A number of pixels to be used as a dimension.
Provide type and enlarge configuration arguments to a resize option.
Functions
Add a formatting option to the Imgproxy.t/0
.
For instance, to add the padding option with a 10px padding on all sides, you can use:
iex> img = Imgproxy.new("http://example.com/image.jpg")
iex> Imgproxy.add_option(img, :padding, [10, 10, 10, 10]) |> to_string()
"https://imgcdn.example.com/insecure/padding:10:10:10:10/aHR0cDovL2V4YW1wbGUuY29tL2ltYWdlLmpwZw"
Crop an image to the given width and height.
Accepts an optional gravity parameter, by default it is "ce:0:0" for center gravity with no offset.
Generate a new Imgproxy.t/0
struct for the given image source URL to fetch the
Info Endpoint.
Generate a new Imgproxy.t/0
struct for the given image source URL.
@spec resize(t(), dimension(), dimension(), resize_opts()) :: t()
Resize an image to the given width and height.
Options include:
- type: "fit" (default), "fill", or "auto"
- enlarge: enlarge if necessary (
false
by default)
Set the file extension (which will produce an image of that type).
For instance, setting the extension to "png" will result in a PNG being created:
iex> img = Imgproxy.new("http://example.com/image.jpg")
iex> Imgproxy.set_extension(img, "png") |> to_string()
"https://imgcdn.example.com/insecure/aHR0cDovL2V4YW1wbGUuY29tL2ltYWdlLmpwZw.png"
Set the gravity option.
Generate an imgproxy URL.
Example
iex> Imgproxy.to_string(Imgproxy.new("https://placekitten.com/200/300"))
"https://imgcdn.example.com/insecure/aHR0cHM6Ly9wbGFjZWtpdHRlbi5jb20vMjAwLzMwMA"