test_webp.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pywebp 作者: anibali 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号