def test_save_as_gif_animated(self): with open('tests/images/newtons_cradle.gif', 'rb') as f: image = WandImage.open(GIFImageFile(f)) output = io.BytesIO() return_value = image.save_as_gif(output) output.seek(0) loaded_image = WandImage.open(GIFImageFile(output)) self.assertTrue(loaded_image.has_animation()) self.assertEqual(loaded_image.get_frame_count(), 34)
def test_jpeg_with_orientation_8(self): with open('tests/images/orientation/landscape_8.jpg', 'rb') as f: image = WandImage.open(JPEGImageFile(f)) image = image.auto_orient() self.assert_orientation_landscape_image_is_correct(image)
def test_resize_animated_gif(self): with open('tests/images/newtons_cradle.gif', 'rb') as f: image = WandImage.open(GIFImageFile(f)) resized_image = image.resize((100, 75)) self.assertTrue(resized_image.has_animation())
def test_animated_gif(self): with open('tests/images/newtons_cradle.gif', 'rb') as f: image = WandImage.open(GIFImageFile(f)) self.assertTrue(image.has_animation()) self.assertEqual(image.get_frame_count(), 34)
def test_jpeg_with_orientation_7(self): with open("tests/images/orientation/landscape_7.jpg", "rb") as f: image = WandImage.open(JPEGImageFile(f)) image = image.auto_orient() self.assert_orientation_landscape_image_is_correct(image)
def test_transparent_gif(self): with open('tests/images/transparent.gif', 'rb') as f: image = WandImage.open(GIFImageFile(f)) self.assertTrue(image.has_alpha()) self.assertFalse(image.has_animation()) # Check that the alpha of pixel 1,1 is 0 self.assertEqual(image.image[1][1].alpha, 0)
def test_resize_transparent_gif(self): with open('tests/images/transparent.gif', 'rb') as f: image = WandImage.open(GIFImageFile(f)) resized_image = image.resize((100, 75)) self.assertTrue(resized_image.has_alpha()) self.assertFalse(resized_image.has_animation()) # Check that the alpha of pixel 1,1 is 0 self.assertAlmostEqual(resized_image.image[1][1].alpha, 0, places=6)
def test_open_webp_lossless(self): original_image = self.image.image lossless_file = self.image.save_as_webp(io.BytesIO(), lossless=True) lossless_image = WandImage.open(lossless_file).image identically = True for x in range(original_image.width): for y in range(original_image.height): original_pixel = original_image[x, y] # don't compare fully transparent pixels if original_pixel.alpha == 0.0: continue if original_pixel != lossless_image[x, y]: identically = False break self.assertTrue(identically)
def setUp(self): with open('tests/images/transparent.png', 'rb') as f: self.image = WandImage.open(PNGImageFile(f))
def test_animated_gif(self): with open('tests/images/newtons_cradle.gif', 'rb') as f: image = WandImage.open(GIFImageFile(f)) self.assertTrue(image.has_animation())
def test_open_webp_w_alpha(self): with open('tests/images/tux_w_alpha.webp', 'rb') as f: image = WandImage.open(WebPImageFile(f)) self.assertTrue(image.has_alpha()) self.assertFalse(image.has_animation())
def setUp(self): with open("tests/images/transparent.png", "rb") as f: self.image = WandImage.open(PNGImageFile(f))