2014-06-10 13:10:47 +04:00
|
|
|
from helper import unittest, PillowTestCase, tearDownModule, lena
|
2012-10-16 00:26:38 +04:00
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
FLIP_LEFT_RIGHT = Image.FLIP_LEFT_RIGHT
|
|
|
|
FLIP_TOP_BOTTOM = Image.FLIP_TOP_BOTTOM
|
|
|
|
ROTATE_90 = Image.ROTATE_90
|
|
|
|
ROTATE_180 = Image.ROTATE_180
|
|
|
|
ROTATE_270 = Image.ROTATE_270
|
|
|
|
|
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
class TestImageTranspose(PillowTestCase):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_sanity(self):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
im = lena()
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
im.transpose(FLIP_LEFT_RIGHT)
|
|
|
|
im.transpose(FLIP_TOP_BOTTOM)
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
im.transpose(ROTATE_90)
|
|
|
|
im.transpose(ROTATE_180)
|
|
|
|
im.transpose(ROTATE_270)
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_roundtrip(self):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
im = lena()
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def transpose(first, second):
|
|
|
|
return im.transpose(first).transpose(second)
|
2013-07-01 02:42:19 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
self.assert_image_equal(
|
|
|
|
im, transpose(FLIP_LEFT_RIGHT, FLIP_LEFT_RIGHT))
|
|
|
|
self.assert_image_equal(
|
|
|
|
im, transpose(FLIP_TOP_BOTTOM, FLIP_TOP_BOTTOM))
|
|
|
|
|
|
|
|
self.assert_image_equal(im, transpose(ROTATE_90, ROTATE_270))
|
|
|
|
self.assert_image_equal(im, transpose(ROTATE_180, ROTATE_180))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
|
|
|
|
# End of file
|