Pillow/Tests/test_file_webp_lossless.py

44 lines
951 B
Python
Raw Normal View History

2014-06-10 13:10:47 +04:00
from helper import unittest, PillowTestCase, tearDownModule, lena
2014-01-21 01:05:30 +04:00
from PIL import Image
try:
from PIL import _webp
except:
2014-06-10 13:10:47 +04:00
pass
# Skip in setUp()
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
class TestFileWebpLossless(PillowTestCase):
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
def setUp(self):
try:
from PIL import _webp
except:
self.skipTest('WebP support not installed')
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
if (_webp.WebPDecoderVersion() < 0x0200):
self.skipTest('lossless not included')
2014-01-21 01:05:30 +04:00
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
2014-06-10 13:10:47 +04:00
lena("RGB").save(temp_file, lossless=True)
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
image = Image.open(temp_file)
image.load()
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
self.assertEqual(image.mode, "RGB")
self.assertEqual(image.size, (128, 128))
self.assertEqual(image.format, "WEBP")
image.load()
image.getdata()
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
self.assert_image_equal(image, lena("RGB"))
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
if __name__ == '__main__':
unittest.main()
2014-01-21 01:05:30 +04:00
2014-06-10 13:10:47 +04:00
# End of file