diff --git a/easy_images/options.py b/easy_images/options.py index 17ee057..eecf31a 100644 --- a/easy_images/options.py +++ b/easy_images/options.py @@ -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: @@ -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: