mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
Added width and height properties
This commit is contained in:
parent
951923f755
commit
afa4cadb23
|
@ -504,6 +504,14 @@ class Image(object):
|
||||||
self.readonly = 0
|
self.readonly = 0
|
||||||
self.pyaccess = None
|
self.pyaccess = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def width(self):
|
||||||
|
return self.size[0]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def height(self):
|
||||||
|
return self.size[1]
|
||||||
|
|
||||||
def _new(self, im):
|
def _new(self, im):
|
||||||
new = Image()
|
new = Image()
|
||||||
new.im = im
|
new.im = im
|
||||||
|
|
|
@ -30,6 +30,15 @@ class TestImage(PillowTestCase):
|
||||||
# self.assertRaises(
|
# self.assertRaises(
|
||||||
# MemoryError, lambda: Image.new("L", (1000000, 1000000)))
|
# 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):
|
def test_invalid_image(self):
|
||||||
if str is bytes:
|
if str is bytes:
|
||||||
import StringIO
|
import StringIO
|
||||||
|
|
Loading…
Reference in New Issue
Block a user