mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Added output checked tests for rotate with center and translate
This commit is contained in:
parent
7228de1491
commit
45138fec9b
|
@ -33,6 +33,7 @@ class TestImageRotate(PillowTestCase):
|
||||||
self.rotate(im, im.mode, angle)
|
self.rotate(im, im.mode, angle)
|
||||||
|
|
||||||
def test_resample(self):
|
def test_resample(self):
|
||||||
|
# Target image creation, inspected by eye.
|
||||||
# >>> im = Image.open('Tests/images/hopper.ppm')
|
# >>> im = Image.open('Tests/images/hopper.ppm')
|
||||||
# >>> im = im.rotate(45, resample=Image.BICUBIC, expand=True)
|
# >>> im = im.rotate(45, resample=Image.BICUBIC, expand=True)
|
||||||
# >>> im.save('Tests/images/hopper_45.png')
|
# >>> im.save('Tests/images/hopper_45.png')
|
||||||
|
@ -45,6 +46,51 @@ class TestImageRotate(PillowTestCase):
|
||||||
im = im.rotate(45, resample=resample, expand=True)
|
im = im.rotate(45, resample=resample, expand=True)
|
||||||
self.assert_image_similar(im, target, epsilon)
|
self.assert_image_similar(im, target, epsilon)
|
||||||
|
|
||||||
|
def test_center_0(self):
|
||||||
|
im = hopper()
|
||||||
|
target = Image.open('Tests/images/hopper_45.png')
|
||||||
|
target_origin = target.size[1]/2
|
||||||
|
target = target.crop((0, target_origin, 128, target_origin + 128))
|
||||||
|
|
||||||
|
im = im.rotate(45, center=(0,0), resample=Image.BICUBIC)
|
||||||
|
|
||||||
|
self.assert_image_similar(im, target, 15)
|
||||||
|
|
||||||
|
def test_center_14(self):
|
||||||
|
im = hopper()
|
||||||
|
target = Image.open('Tests/images/hopper_45.png')
|
||||||
|
target_origin = target.size[1] / 2 - 14
|
||||||
|
target = target.crop((6, target_origin, 128 + 6, target_origin + 128))
|
||||||
|
|
||||||
|
im = im.rotate(45, center=(14,14), resample=Image.BICUBIC)
|
||||||
|
|
||||||
|
self.assert_image_similar(im, target, 10)
|
||||||
|
|
||||||
|
def test_translate(self):
|
||||||
|
im = hopper()
|
||||||
|
target = Image.open('Tests/images/hopper_45.png')
|
||||||
|
target_origin = (target.size[1] / 2 - 64) - 5
|
||||||
|
target = target.crop((target_origin, target_origin,
|
||||||
|
target_origin + 128, target_origin + 128))
|
||||||
|
|
||||||
|
im = im.rotate(45, translate=(5,5), resample=Image.BICUBIC)
|
||||||
|
|
||||||
|
self.assert_image_similar(im, target, 1)
|
||||||
|
|
||||||
|
def test_fastpath_center(self):
|
||||||
|
# if the center is -1,-1 and we rotate by 90<=x<=270 the
|
||||||
|
# resulting image should be black
|
||||||
|
for angle in (90, 180, 270):
|
||||||
|
im = hopper().rotate(angle, center=(-1,-1))
|
||||||
|
self.assert_image_equal(im, Image.new('RGB', im.size, 'black'))
|
||||||
|
|
||||||
|
def test_fastpath_translate(self):
|
||||||
|
# if we post-translate by -128
|
||||||
|
# resulting image should be black
|
||||||
|
for angle in (0, 90, 180, 270):
|
||||||
|
im = hopper().rotate(angle, translate=(-128,-128))
|
||||||
|
self.assert_image_equal(im, Image.new('RGB', im.size, 'black'))
|
||||||
|
|
||||||
def test_center(self):
|
def test_center(self):
|
||||||
im = hopper()
|
im = hopper()
|
||||||
self.rotate(im, im.mode, 45, center=(0, 0))
|
self.rotate(im, im.mode, 45, center=(0, 0))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user