Py3. sigh

This commit is contained in:
wiredfool 2013-09-30 22:32:50 -07:00
parent 46c58560ba
commit 7546e1fb17

View File

@ -7,7 +7,7 @@ def test_extent():
(w,h) = im.size (w,h) = im.size
transformed = im.transform(im.size, Image.EXTENT, transformed = im.transform(im.size, Image.EXTENT,
(0,0, (0,0,
w/2,h/2), # ul -> lr w//2,h//2), # ul -> lr
Image.BILINEAR) Image.BILINEAR)
@ -20,8 +20,8 @@ def test_quad():
im = lena('RGB') im = lena('RGB')
(w,h) = im.size (w,h) = im.size
transformed = im.transform(im.size, Image.QUAD, transformed = im.transform(im.size, Image.QUAD,
(0,0,0,h/2, (0,0,0,h//2,
w/2,h/2,w/2,0), # ul -> ccw around quad w//2,h//2,w//2,0), # ul -> ccw around quad
Image.BILINEAR) Image.BILINEAR)
scaled = im.resize((w*2, h*2), Image.BILINEAR).crop((0,0,w,h)) scaled = im.resize((w*2, h*2), Image.BILINEAR).crop((0,0,w,h))
@ -33,29 +33,29 @@ def test_mesh():
im = lena('RGBA') im = lena('RGBA')
(w,h) = im.size (w,h) = im.size
transformed = im.transform(im.size, Image.MESH, transformed = im.transform(im.size, Image.MESH,
[((0,0,w/2,h/2), # box [((0,0,w//2,h//2), # box
(0,0,0,h, (0,0,0,h,
w,h,w,0)), # ul -> ccw around quad w,h,w,0)), # ul -> ccw around quad
((w/2,h/2,w,h), # box ((w//2,h//2,w,h), # box
(0,0,0,h, (0,0,0,h,
w,h,w,0))], # ul -> ccw around quad w,h,w,0))], # ul -> ccw around quad
Image.BILINEAR) Image.BILINEAR)
transformed.save('transformed.png') transformed.save('transformed.png')
scaled = im.resize((w/2, h/2), Image.BILINEAR) scaled = im.resize((w//2, h//2), Image.BILINEAR)
checker = Image.new('RGBA', im.size) checker = Image.new('RGBA', im.size)
checker.paste(scaled, (0,0)) checker.paste(scaled, (0,0))
checker.paste(scaled, (w/2,h/2)) checker.paste(scaled, (w//2,h//2))
assert_image_equal(transformed, checker) assert_image_equal(transformed, checker)
# now, check to see that the extra area is (0,0,0,0) # now, check to see that the extra area is (0,0,0,0)
blank = Image.new('RGBA', (w/2,h/2), (0,0,0,0)) blank = Image.new('RGBA', (w//2,h//2), (0,0,0,0))
assert_image_equal(blank, transformed.crop((w/2,0,w,h/2))) assert_image_equal(blank, transformed.crop((w//2,0,w,h//2)))
assert_image_equal(blank, transformed.crop((0,h/2,w/2,h))) assert_image_equal(blank, transformed.crop((0,h//2,w//2,h)))
def test_blank_fill(): def test_blank_fill():