Avoid some bad combinations of default values

- Avoid setting image.fixedsize default True when image.scale is
  specified different than "true" or "both" by the user.
- Avoid calculating the missing dimension unless image.fixedsize
  is actually True. It might have been specified False by the user.
This commit is contained in:
KV 2020-08-19 09:36:33 +02:00
parent c21707980e
commit 285a28dff6

View File

@ -28,8 +28,11 @@ class Image:
else "true" # When only one dimension is specified. else "true" # When only one dimension is specified.
if self.fixedsize is None: if self.fixedsize is None:
self.fixedsize = self.width or self.height # Normally equal to (self.width or self.height), but the user might override self.scale.
self.fixedsize = str(self.scale).lower() in ["true", "both"]
if self.fixedsize:
# If only one dimension is specified, compute the other because both are required.
if self.height: if self.height:
if not self.width: if not self.width:
self.width = self.height # Assuming 1:1 aspect ratio for now. self.width = self.height # Assuming 1:1 aspect ratio for now.