Commits

Mikhail Korobov  committed d7d748b

(backwards incompatible) bbox.width and bbox.heigth properties; Layer.width/height properties are removed

  • Participants
  • Parent commits ddba8fe

Comments (0)

Files changed (2)

     >>> layer.bbox
     BBox(x1=40, y1=72, x2=83, y2=134)
 
-    >>> layer.width, layer.height
+    >>> layer.bbox.width, layer.bbox.height
     (43, 62)
 
     >>> layer.visible, layer.opacity, layer.blend_mode

File src/psd_tools/user_api/psd_image.py

 from psd_tools.user_api.pil_support import composite_image_to_PIL, layer_to_PIL
 from psd_tools.user_api import pymaging_support
 
-BBox = collections.namedtuple('BBox', 'x1, y1, x2, y2')
+class BBox(collections.namedtuple('BBox', 'x1, y1, x2, y2')):
+    @property
+    def width(self):
+        return self.x2-self.x1
+
+    @property
+    def height(self):
+        return self.y2-self.y1
+
 
 class _RawLayer(object):
     """
         info = self._info
         return BBox(info.left, info.top, info.right, info.bottom)
 
-    @property
-    def width(self):
-        return self._info.width()
-
-    @property
-    def height(self):
-        return self._info.height()
-
     def __repr__(self):
+        bbox = self.bbox
         return "<psd_tools.Layer: %r, size=%dx%d, x=%d, y=%d>" % (
-            self.name, self.width, self.height, self._info.left, self._info.top)
+            self.name, bbox.width, bbox.height, bbox.x1, bbox.y1)
 
 
 class Group(_RawLayer):