Let Rectangle.downscaled_to and Rectangle.rescaled_to return a
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 24 Feb 2006 07:48:56 +0000 (07:48 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 24 Feb 2006 07:48:56 +0000 (07:48 +0000)
rectangle with width and height at least 1.

src/packages/kofoto/rectangle.py

index 3c78767..a1dea9f 100644 (file)
@@ -110,6 +110,8 @@ class Rectangle:
         if h > limit[1]:
             w = limit[1] * w // h
             h = limit[1]
+        w = max(1, w)
+        h = max(1, h)
         return self.__class__(w, h)
 
     def fits_within(self, limit):
@@ -143,4 +145,6 @@ class Rectangle:
         if h > limit[1]:
             w = limit[1] * w // h
             h = limit[1]
+        w = max(1, w)
+        h = max(1, h)
         return self.__class__(w, h)