Skip to content

Commit

Permalink
Merge pull request #112 from BanchanArt/master
Browse files Browse the repository at this point in the history
add support for setting pixel cache limits
  • Loading branch information
route committed Aug 22, 2022
2 parents 3e0852b + 41813d1 commit f495f05
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/mogrify.ex
Expand Up @@ -202,6 +202,7 @@ defmodule Mogrify do
defp normalize_arguments({option, nil}), do: ["-#{option}"]
defp normalize_arguments({"+" <> option, params}), do: ["+#{option}", to_string(params)]
defp normalize_arguments({"-" <> option, params}), do: ["-#{option}", to_string(params)]
defp normalize_arguments({:limit, params}), do: ~w(-limit #{params})
defp normalize_arguments({option, params}), do: ["-#{option}", to_string(params)]

@doc """
Expand Down Expand Up @@ -315,6 +316,21 @@ defmodule Mogrify do
%{image | operations: image.operations ++ [quality: params]}
end

@doc """
Sets a pixel cache resource limit.
"""
def limit(image, type, value) do
image
|> limit("#{type} #{value}")
end

@doc """
Sets a pixel cache resource limit, in the form of a space-separated string (e.g. `"memory 30mb"`).
"""
def limit(image, params) do
%{image | operations: image.operations ++ [limit: params]}
end

@doc """
Extends the image to the specified dimensions.
"""
Expand Down

0 comments on commit f495f05

Please sign in to comment.