Esempio n. 1
0
    def test_save_as_gif_converts_back_to_supported_mode(self):
        output = io.BytesIO()

        with open('tests/images/transparent.gif', 'rb') as f:
            backend = pillow_backend.PillowBackend.from_file(f)
            backend.image = backend.image.convert('RGB')
        pillow_backend.save_as_gif(backend, output)

        image = backend.get_pillow_image().open(output)
        self.assertEqual(image.mode, 'P')
Esempio n. 2
0
    def test_save_transparent_gif(self):
        with open('tests/images/transparent.gif', 'rb') as f:
            backend = pillow_backend.PillowBackend.from_file(f)

        # Save it into memory
        f = io.BytesIO()
        pillow_backend.save_as_gif(backend, f)

        # Reload it
        f.seek(0)
        backend = pillow_backend.PillowBackend.from_file(f)

        self.assertTrue(pillow_backend.has_alpha(backend))
        self.assertFalse(pillow_backend.has_animation(backend))

        # Check that the alpha of pixel 1,1 is 0
        self.assertEqual(backend.image.convert('RGBA').getpixel((1, 1))[3], 0)
Esempio n. 3
0
    def test_save_as_gif(self):
        output = io.BytesIO()
        pillow_backend.save_as_gif(self.backend, output)
        output.seek(0)

        self.assertEqual(imghdr.what(output), 'gif')