def test_image_simple(self):
width = 256
height = 64
img = Image.new('RGB', (width, height))
draw = ImageDraw.Draw(img)
draw.rectangle([0, 0, width-1, height-1], fill=(0, 0, 255))
draw.rectangle([0, 0, (width/4-1), height-1], fill=(255, 0, 0))
with TemporaryDirectory() as tmpdir:
file_name = os.path.join(tmpdir, 'image.webp')
webp.save_image(img, file_name, lossless=True)
dec_img = webp.load_image(file_name, 'RGB')
actual = np.asarray(dec_img, dtype=np.uint8)
expected = np.asarray(img, dtype=np.uint8)
np.testing.assert_array_equal(actual, expected)
评论列表
文章目录