Skip to content

Commit

Permalink
Fix vibrance range and change default threshold to 60
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Jul 18, 2024
1 parent b575c58 commit 3fa54ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/image.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8628,9 +8628,9 @@ defmodule Image do
* `image` is any `t:Vix.Vips.Image.t/0`.
* `saturation` is any float greater than `0.0`. A number less
than `1.0` means reduce saturation. A number greater than `1.0`
means increase saturation.
* `saturation` is any float in the range `-1.0` to `+1.0`.
A number less than `1.0` means reduce saturation. A
number greater than `1.0` means increase saturation.
* `options` is a keyword list of options.
Expand All @@ -8656,7 +8656,7 @@ defmodule Image do
@spec vibrance(image :: Vimage.t(), vibrance :: float(), options :: Options.Vibrance.vibrance_options()) ::
{:ok, Vimage.t()} | {:error, error_message()}

def vibrance(%Vimage{} = image, vibrance, options \\ []) when is_multiplier(vibrance) do
def vibrance(%Vimage{} = image, vibrance, options \\ []) when vibrance >= -1.0 and vibrance <= 1.0 do
use Image.Math

with {:ok, options} <- Options.Vibrance.validate_options(options) do
Expand Down Expand Up @@ -8693,17 +8693,17 @@ defmodule Image do
* `image` is any `t:Vix.Vips.Image.t/0`.
* `saturation` is any float greater than `0.0`. A number less
than `1.0` means reduce saturation. A number greater than `1.0`
means increase saturation.
* `saturation` is any float in the range `-1.0` to `+1.0`.
A number less than `1.0` means reduce saturation. A
number greater than `1.0` means increase saturation.
* `options` is a keyword list of options.
### Options
* `:threshold` is the saturation level above which no
adjustment is made. The range is `1..100` with a default
of `70`.
of `60`.
### Returns
Expand All @@ -8721,7 +8721,7 @@ defmodule Image do
@spec vibrance!(image :: Vimage.t(), vibrance :: float(), options :: Options.Vibrance.vibrance_options()) ::
Vimage.t() | no_return()

def vibrance!(%Vimage{} = image, vibrance, options \\ []) when is_multiplier(vibrance) do
def vibrance!(%Vimage{} = image, vibrance, options \\ []) do
case vibrance(image, vibrance, options) do
{:ok, image} -> image
{:error, reason} -> raise Image.Error, reason
Expand Down
2 changes: 1 addition & 1 deletion lib/image/options/vibrance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule Image.Options.Vibrance do
"""
@type vibrance_options :: [vibrance_option()] | map()

@default_vibrance_threshold 70
@default_vibrance_threshold 60

@doc false
def default_vibrance_threshold do
Expand Down

0 comments on commit 3fa54ce

Please sign in to comment.