Pillow/Tests/test_file_webp_lossless.py
Jason Douglas e534991409 - Styling changes to be C89-conformant
- Change WebPAnimEncoder/Decoder to use RGBX mode instead of RGB (since internally it is using RGBA always)
2017-09-27 17:10:25 -07:00

42 lines
941 B
Python

from helper import unittest, PillowTestCase, hopper
from PIL import Image
try:
from PIL import _webp
except ImportError:
pass
# Skip in setUp()
class TestFileWebpLossless(PillowTestCase):
def setUp(self):
try:
from PIL import _webp
except:
self.skipTest('WebP support not installed')
if (_webp.WebPDecoderVersion() < 0x0200):
self.skipTest('lossless not included')
def test_write_lossless_rgb(self):
temp_file = self.tempfile("temp.webp")
hopper("RGBX").save(temp_file, lossless=True)
image = Image.open(temp_file)
image.load()
self.assertEqual(image.mode, "RGBX")
self.assertEqual(image.size, (128, 128))
self.assertEqual(image.format, "WEBP")
image.load()
image.getdata()
self.assert_image_equal(image, hopper("RGBX"))
if __name__ == '__main__':
unittest.main()