Pillow/Tests/test_image_transpose.py

45 lines
1.0 KiB
Python
Raw Normal View History

2014-07-07 21:03:50 +04:00
from helper import unittest, PillowTestCase, lena
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):
2014-06-10 13:10:47 +04:00
def test_sanity(self):
2014-06-10 13:10:47 +04:00
im = lena()
2014-06-10 13:10:47 +04:00
im.transpose(FLIP_LEFT_RIGHT)
im.transpose(FLIP_TOP_BOTTOM)
2014-06-10 13:10:47 +04:00
im.transpose(ROTATE_90)
im.transpose(ROTATE_180)
im.transpose(ROTATE_270)
2014-06-10 13:10:47 +04:00
def test_roundtrip(self):
2014-06-10 13:10:47 +04:00
im = lena()
2014-06-10 13:10:47 +04:00
def transpose(first, second):
return im.transpose(first).transpose(second)
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