Skip to content

Commit

Permalink
Fix parsing crop=False
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyChris committed Aug 4, 2024
1 parent 5d1cc81 commit 957fab6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions easy_images/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def __init__(self, bound=None, string="", /, **options):
for key, value in bound.__dict__.items():
context[key] = value
for key in self.__slots__:
value = options.get(key)
if isinstance(value, Variable):
value = value.resolve(context)
if value or value == 0:
if key in options:
value = options[key]
if isinstance(value, Variable):
value = value.resolve(context)
parse_func = getattr(self, f"parse_{key}")
value = parse_func(value, **options)
elif key in self._defaults:
Expand All @@ -92,7 +92,9 @@ def parse_quality(value, **options) -> int:
raise ValueError(f"Invalid quality value {value}")

@staticmethod
def parse_crop(value, **options) -> tuple[float, float]:
def parse_crop(value, **options) -> tuple[float, float] | None:
if not value:
return None
if value is True:
return (0.5, 0.5)
try:
Expand Down

0 comments on commit 957fab6

Please sign in to comment.