Esempio n. 1
0
def test_composable_image_crop_offset():
    img_size = (128, 64)
    crop_size = (10, 10)
    img = Image.new("RGB", img_size)
    ci = ComposableImage(img, offset=(20, 20))
    cropped_img = ci.image(crop_size)
    assert cropped_img.size == crop_size
Esempio n. 2
0
def test_composable_image_crop_size_greater_than_image_size():
    img_size = (128, 64)
    crop_size = (1000, 1000)
    img = Image.new("RGB", img_size)
    ci = ComposableImage(img)
    cropped_img = ci.image(crop_size)
    assert cropped_img.size == img_size
Esempio n. 3
0
def test_composable_image_crop_same():
    img_size = (128, 64)
    crop_size = img_size
    img = Image.new("RGB", img_size)
    ci = ComposableImage(img)
    cropped_img = ci.image(crop_size)
    assert cropped_img.size == crop_size
Esempio n. 4
0
def test_composable_image_ctor():
    pos = (78, 12)
    offs = (90, 12)
    img_size = (123, 234)
    img = Image.new("RGB", img_size)
    ci = ComposableImage(img)
    ci.position = pos
    ci.offset = offs
    assert ci.position == pos
    assert ci.offset == offs
    assert ci.width == img_size[0]
    assert ci.height == img_size[1]
    assert isinstance(ci.image((1, 1)), PIL.Image.Image)
Esempio n. 5
0
def test_composable_image_image():
    ci = ComposableImage(Image.new("RGB", (1, 1)))
    with pytest.raises(AssertionError):
        ci.image((0, 0))

    with pytest.raises(AssertionError):
        ci.image((1, 0))

    with pytest.raises(AssertionError):
        ci.image((0, 1))