mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge pull request #1304 from radarhere/size
Added width and height properties
This commit is contained in:
commit
4cf2240093
|
@ -504,6 +504,14 @@ class Image(object):
|
|||
self.readonly = 0
|
||||
self.pyaccess = None
|
||||
|
||||
@property
|
||||
def width(self):
|
||||
return self.size[0]
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
return self.size[1]
|
||||
|
||||
def _new(self, im):
|
||||
new = Image()
|
||||
new.im = im
|
||||
|
|
|
@ -30,6 +30,15 @@ class TestImage(PillowTestCase):
|
|||
# self.assertRaises(
|
||||
# MemoryError, lambda: Image.new("L", (1000000, 1000000)))
|
||||
|
||||
def test_width_height(self):
|
||||
im = Image.new("RGB", (1, 2))
|
||||
self.assertEqual(im.width, 1)
|
||||
self.assertEqual(im.height, 2)
|
||||
|
||||
im.size = (3, 4)
|
||||
self.assertEqual(im.width, 3)
|
||||
self.assertEqual(im.height, 4)
|
||||
|
||||
def test_invalid_image(self):
|
||||
if str is bytes:
|
||||
import StringIO
|
||||
|
|
Loading…
Reference in New Issue
Block a user