mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from helper import unittest, PillowTestCase, tearDownModule, lena
|
|
|
|
from PIL import Image
|
|
|
|
|
|
class TestImageGetProjection(PillowTestCase):
|
|
|
|
def test_sanity(self):
|
|
|
|
im = lena()
|
|
|
|
projection = im.getprojection()
|
|
|
|
self.assertEqual(len(projection), 2)
|
|
self.assertEqual(len(projection[0]), im.size[0])
|
|
self.assertEqual(len(projection[1]), im.size[1])
|
|
|
|
# 8-bit image
|
|
im = Image.new("L", (10, 10))
|
|
self.assertEqual(im.getprojection()[0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
|
self.assertEqual(im.getprojection()[1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
|
im.paste(255, (2, 4, 8, 6))
|
|
self.assertEqual(im.getprojection()[0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0])
|
|
self.assertEqual(im.getprojection()[1], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0])
|
|
|
|
# 32-bit image
|
|
im = Image.new("RGB", (10, 10))
|
|
self.assertEqual(im.getprojection()[0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
|
self.assertEqual(im.getprojection()[1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
|
im.paste(255, (2, 4, 8, 6))
|
|
self.assertEqual(im.getprojection()[0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0])
|
|
self.assertEqual(im.getprojection()[1], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|
|
|
|
# End of file
|