Pillow/Tests/test_file_webp_lossless.py

31 lines
872 B
Python
Raw Normal View History

import pytest
2014-01-21 01:05:30 +04:00
from PIL import Image
from .helper import PillowTestCase, assert_image_equal, hopper
_webp = pytest.importorskip("PIL._webp", reason="WebP support not installed")
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
class TestFileWebpLossless(PillowTestCase):
def setUp(self):
2018-10-02 11:55:28 +03:00
if _webp.WebPDecoderVersion() < 0x0200:
2019-06-13 18:54:11 +03:00
self.skipTest("lossless not included")
2014-01-21 01:05:30 +04:00
self.rgb_mode = "RGB"
2014-06-10 13:10:47 +04:00
def test_write_lossless_rgb(self):
temp_file = self.tempfile("temp.webp")
2014-01-21 01:05:30 +04:00
hopper(self.rgb_mode).save(temp_file, lossless=True)
2014-01-21 01:05:30 +04:00
2019-11-25 23:03:23 +03:00
with Image.open(temp_file) as image:
image.load()
2014-01-21 01:05:30 +04:00
2019-11-25 23:03:23 +03:00
self.assertEqual(image.mode, self.rgb_mode)
self.assertEqual(image.size, (128, 128))
self.assertEqual(image.format, "WEBP")
image.load()
image.getdata()
2014-01-21 01:05:30 +04:00
assert_image_equal(image, hopper(self.rgb_mode))