本文整理汇总了Python中ImageUtils.ImageUtils.concat方法的典型用法代码示例。如果您正苦于以下问题:Python ImageUtils.concat方法的具体用法?Python ImageUtils.concat怎么用?Python ImageUtils.concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageUtils.ImageUtils
的用法示例。
在下文中一共展示了ImageUtils.concat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ImageUtilsTest
# 需要导入模块: from ImageUtils import ImageUtils [as 别名]
# 或者: from ImageUtils.ImageUtils import concat [as 别名]
class ImageUtilsTest(unittest.TestCase):
def setUp(self):
self.image1 = Image.open('test1.png')
# test2.png Breite: 200px # Hoehe: 220px
self.image2 = Image.open('test2.png')
self.imageUtils = ImageUtils()
def test_makeImagesOfCorners_numbe_of_elements(self):
images = self.imageUtils.makeImagesOfCorners(50)
self.assertEqual(4, len(images))
def test_makeImagesOfCorners_size(self):
border = 50
top, right, bottom, left = self.imageUtils.makeImagesOfCorners(border)
self.assertEqual(top.size, (self.imageUtils.getScreenSize()[0], border))
self.assertEqual(right.size, (border, self.imageUtils.getScreenSize()[1]))
self.assertEqual(bottom.size, (self.imageUtils.getScreenSize()[0], border))
self.assertEqual(left.size, (border, self.imageUtils.getScreenSize()[1]))
def test_makeImagesOfCorners_small_border(self):
with self.assertRaises(ValueError):
self.imageUtils.makeImagesOfCorners(0)
self.imageUtils.makeImagesOfCorners(-1)
def test_concat_too_few(self):
with self.assertRaises(ValueError):
self.imageUtils.concat(())
self.imageUtils.concat((self.image1))
def test_concat_proper_size(self):
images = (self.image2, self.image2)
concated = self.imageUtils.concat(images)
width_expected = 200 + 200
height_expected = 220
width_actual, height_actual = concated.size
self.assertEqual(width_expected, width_actual)
self.assertEqual(height_expected, height_actual)
def test_concat_stripe_proper_size(self):
images = (self.image2, self.image2)
concated = self.imageUtils.concatStripe(images)
width_expected = 220 + 220
height_expected = 200
width_actual, height_actual = concated.size
# TODO:
# self.assertEqual( width_expected, width_actual )
# self.assertEqual( height_expected, height_actual )
def test_split_images_into_chunks_number_of_elements(self):
count = 4
chunks = self.imageUtils.splitImageIntoChunks(self.image2, count)
self.assertEqual(count, len(chunks))
def test_split_images_into_chunks_width(self):
count = 4
chunks = self.imageUtils.splitImageIntoChunks(self.image2, count)
expected_width_per_chunk = self.image2.size[0] / count;
[self.assertEqual(expected_width_per_chunk, image.size[0]) for image in chunks]
def test_split_images_into_chunks_width2(self):
count = 4
chunks = self.imageUtils.splitImageIntoChunks(self.image1, count)
chunks.pop(len(chunks) - 1)
expected_width_per_chunk = self.image2.size[0] / count;
[image.show() for image in chunks]
[self.assertEqual(expected_width_per_chunk, image.size[0]) for image in chunks]