本文整理汇总了Python中willow.plugins.pillow.PillowImage.open方法的典型用法代码示例。如果您正苦于以下问题:Python PillowImage.open方法的具体用法?Python PillowImage.open怎么用?Python PillowImage.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类willow.plugins.pillow.PillowImage
的用法示例。
在下文中一共展示了PillowImage.open方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_jpeg_with_orientation_8
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def test_jpeg_with_orientation_8(self):
with open('tests/images/orientation/landscape_8.jpg', 'rb') as f:
image = PillowImage.open(JPEGImageFile(f))
image = image.auto_orient()
self.assert_orientation_landscape_image_is_correct(image)
示例2: setUp
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def setUp(self):
with open('tests/images/people.jpg', 'rb') as f:
# Open the image via Pillow
pillow_image = PillowImage.open(JPEGImageFile(f))
buffer_rgb = pillow_image.to_buffer_rgb()
colour_image = OpenCVColorImage.from_buffer_rgb(buffer_rgb)
self.image = OpenCVGrayscaleImage.from_color(colour_image)
示例3: test_resize_animated_gif
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def test_resize_animated_gif(self):
with open('tests/images/newtons_cradle.gif', 'rb') as f:
image = PillowImage.open(GIFImageFile(f))
resized_image = image.resize((100, 75))
self.assertFalse(resized_image.has_alpha())
self.assertTrue(resized_image.has_animation())
示例4: test_save_transparent_gif
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def test_save_transparent_gif(self):
with open('tests/images/transparent.gif', 'rb') as f:
image = PillowImage.open(GIFImageFile(f))
# Save it into memory
f = io.BytesIO()
image.save_as_gif(f)
# Reload it
f.seek(0)
image = PillowImage.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.convert('RGBA').getpixel((1, 1))[3], 0)
示例5: test_transparent_gif
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def test_transparent_gif(self):
with open('tests/images/transparent.gif', 'rb') as f:
image = PillowImage.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.convert('RGBA').getpixel((1, 1))[3], 0)
示例6: test_save_as_gif_converts_back_to_supported_mode
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def test_save_as_gif_converts_back_to_supported_mode(self):
output = io.BytesIO()
with open('tests/images/transparent.gif', 'rb') as f:
image = PillowImage.open(GIFImageFile(f))
image.image = image.image.convert('RGB')
image.save_as_gif(output)
output.seek(0)
image = _PIL_Image().open(output)
self.assertEqual(image.mode, 'P')
示例7: test_open_webp_w_alpha
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def test_open_webp_w_alpha(self):
with open('tests/images/tux_w_alpha.webp', 'rb') as f:
image = PillowImage.open(WebPImageFile(f))
self.assertTrue(image.has_alpha())
self.assertFalse(image.has_animation())
示例8: setUp
# 需要导入模块: from willow.plugins.pillow import PillowImage [as 别名]
# 或者: from willow.plugins.pillow.PillowImage import open [as 别名]
def setUp(self):
with open('tests/images/transparent.png', 'rb') as f:
self.image = PillowImage.open(PNGImageFile(f))