当前位置: 首页>>代码示例>>Python>>正文


Python PillowImage.open方法代码示例

本文整理汇总了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)
开发者ID:torchbox,项目名称:Willow,代码行数:9,代码来源:test_pillow.py

示例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)
开发者ID:KarimJedda,项目名称:Willow,代码行数:9,代码来源:test_opencv.py

示例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())
开发者ID:torchbox,项目名称:Willow,代码行数:10,代码来源:test_pillow.py

示例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)
开发者ID:torchbox,项目名称:Willow,代码行数:19,代码来源:test_pillow.py

示例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)
开发者ID:torchbox,项目名称:Willow,代码行数:11,代码来源:test_pillow.py

示例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')
开发者ID:torchbox,项目名称:Willow,代码行数:14,代码来源:test_pillow.py

示例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())
开发者ID:torchbox,项目名称:Willow,代码行数:8,代码来源:test_pillow.py

示例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))
开发者ID:torchbox,项目名称:Willow,代码行数:5,代码来源:test_pillow.py


注:本文中的willow.plugins.pillow.PillowImage.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。