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


Python Engine.resize方法代码示例

本文整理汇总了Python中thumbor.engines.pil.Engine.resize方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.resize方法的具体用法?Python Engine.resize怎么用?Python Engine.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在thumbor.engines.pil.Engine的用法示例。


在下文中一共展示了Engine.resize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_convert_png_1bit_to_png

# 需要导入模块: from thumbor.engines.pil import Engine [as 别名]
# 或者: from thumbor.engines.pil.Engine import resize [as 别名]
 def test_convert_png_1bit_to_png(self):
     engine = Engine(self.context)
     with open(join(STORAGE_PATH, '1bit.png'), 'r') as im:
         buffer = im.read()
     engine.load(buffer, '.png')
     engine.resize(10, 10)
     mode, _ = engine.image_data_as_rgb()
     expect(mode).to_equal('RGBA')
开发者ID:RealGeeks,项目名称:thumbor,代码行数:10,代码来源:test_pil.py

示例2: test_resize_truncated_image

# 需要导入模块: from thumbor.engines.pil import Engine [as 别名]
# 或者: from thumbor.engines.pil.Engine import resize [as 别名]
 def test_resize_truncated_image(self):
     engine = Engine(self.context)
     with open(join(STORAGE_PATH, 'BlueSquare_truncated.jpg'), 'r') as im:
         buffer = im.read()
     engine.load(buffer, '.jpg')
     engine.resize(10, 10)
     mode, _ = engine.image_data_as_rgb()
     expect(mode).to_equal('RGB')
开发者ID:RealGeeks,项目名称:thumbor,代码行数:10,代码来源:test_pil.py

示例3: test_convert_png_1bit_to_png

# 需要导入模块: from thumbor.engines.pil import Engine [as 别名]
# 或者: from thumbor.engines.pil.Engine import resize [as 别名]
 def test_convert_png_1bit_to_png(self):
     engine = Engine(self.context)
     with open(join(STORAGE_PATH, '1bit.png'), 'r') as im:
         buffer = im.read()
     engine.load(buffer, '.png')
     engine.resize(10, 10)
     mode, _ = engine.image_data_as_rgb()
     expect(mode).to_equal('P')  # Note that this is not a true 1bit image, it's 8bit in black/white.
开发者ID:scorphus,项目名称:thumbor,代码行数:10,代码来源:test_pil.py

示例4: test_convert_should_preserve_palette_mode

# 需要导入模块: from thumbor.engines.pil import Engine [as 别名]
# 或者: from thumbor.engines.pil.Engine import resize [as 别名]
 def test_convert_should_preserve_palette_mode(self):
     engine = Engine(self.context)
     with open(join(STORAGE_PATH, '256_color_palette.png'), 'r') as im:
         buffer = im.read()
     engine.load(buffer, '.png')
     engine.resize(10, 10)
     mode, _ = engine.image_data_as_rgb()
     expect(mode).to_equal('P')
开发者ID:scorphus,项目名称:thumbor,代码行数:10,代码来源:test_pil.py

示例5: test_should_preserve_png_transparency

# 需要导入模块: from thumbor.engines.pil import Engine [as 别名]
# 或者: from thumbor.engines.pil.Engine import resize [as 别名]
    def test_should_preserve_png_transparency(self):
        engine = Engine(self.context)

        with open(join(STORAGE_PATH, 'paletted-transparent.png'), 'r') as im:
            buffer = im.read()

        engine.load(buffer, 'png')
        expect(engine.original_mode).to_equal('P')
        engine.resize(200, 150)

        img = Image.open(BytesIO(engine.read('.png')))

        expect(img.mode).to_equal('P')
        expect(img.format.lower()).to_equal('png')

        transparent_pixels_count = sum(img.convert('RGBA')
                                       .split()[3]  # Get alpha channel
                                       .point(lambda x: 0 if x else 1)  # return 1 if pixel is transparent, 0 otherwise
                                       .getdata())

        # Image has total of 200x150=30000 pixels. Most of them should be transparent
        expect(transparent_pixels_count).to_be_greater_than(19000)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:24,代码来源:test_pil.py


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