Esempio n. 1
0
    def test_write_rgba(self):
        """
        Can we write a RGBA mode file to webp without error.
        Does it have the bits we expect?
        """

        temp_file = self.tempfile("temp.webp")

        pil_image = Image.new("RGBA", (10, 10), (255, 0, 0, 20))
        pil_image.save(temp_file)

        if _webp.WebPDecoderBuggyAlpha(self):
            return

        image = Image.open(temp_file)
        image.load()

        self.assertEqual(image.mode, "RGBA")
        self.assertEqual(image.size, (10, 10))
        self.assertEqual(image.format, "WEBP")
        image.load()
        image.getdata()

        # early versions of webp are known to produce higher deviations:
        # deal with it
        if _webp.WebPDecoderVersion(self) <= 0x201:
            self.assert_image_similar(image, pil_image, 3.0)
        else:
            self.assert_image_similar(image, pil_image, 1.0)
    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 setUp(self):
        if not HAVE_WEBP:
            self.skipTest('WebP support not installed')
            return

        if _webp.WebPDecoderVersion() < 0x0200:
            self.skipTest('lossless not included')

        self.rgb_mode = "RGB"
    def setUp(self):
        if not HAVE_WEBP:
            self.skipTest('WebP support not installed')
            return

        if (_webp.WebPDecoderVersion() < 0x0200):
            self.skipTest('lossless not included')

        # WebPAnimDecoder only returns RGBA or RGBX, never RGB
        self.rgb_mode = "RGBX" if _webp.HAVE_WEBPANIM else "RGB"
Esempio n. 5
0
 def test_version(self):
     _webp.WebPDecoderVersion()
     _webp.WebPDecoderBuggyAlpha()
Esempio n. 6
0
def test_version():
    assert_no_exception(lambda: _webp.WebPDecoderVersion())
    assert_no_exception(lambda: _webp.WebPDecoderBuggyAlpha())
Esempio n. 7
0
 def test_version(self):
     _webp.WebPDecoderVersion()
     _webp.WebPDecoderBuggyAlpha()
     assert re.search(r"\d+\.\d+\.\d+$", features.version_module("webp"))
Esempio n. 8
0
from tester import *

from PIL import Image

try:
    from PIL import _webp
except:
    skip('webp support not installed')

if (_webp.WebPDecoderVersion() < 0x0200):
    skip('lossless not included')


def test_write_lossless_rgb():
    temp_file = tempfile("temp.webp")

    lena("RGB").save(temp_file, lossless=True)

    image = Image.open(temp_file)
    image.load()

    assert_equal(image.mode, "RGB")
    assert_equal(image.size, (128, 128))
    assert_equal(image.format, "WEBP")
    assert_no_exception(lambda: image.load())
    assert_no_exception(lambda: image.getdata())

    assert_image_equal(image, lena("RGB"))