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


Python Engine.get_image_size方法代码示例

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


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

示例1: test_retina

# 需要导入模块: from sorl.thumbnail.engines.pil_engine import Engine [as 别名]
# 或者: from sorl.thumbnail.engines.pil_engine.Engine import get_image_size [as 别名]
    def test_retina(self):
        get_thumbnail(self.im, '50x50')

        actions = [
            # save regular resolution, same as in StorageTestCase
            'open: retina.jpg',
            'save: test/cache/19/10/1910dc350bbe9ee55fd9d8d3d5e38e19.jpg',
            'get_available_name: test/cache/19/10/1910dc350bbe9ee55fd9d8d3d5e38e19.jpg',
            'exists: test/cache/19/10/1910dc350bbe9ee55fd9d8d3d5e38e19.jpg',

            # save the 1.5x resolution version
            'save: test/cache/19/10/[email protected]',
            'get_available_name: test/cache/19/10/[email protected]',
            'exists: test/cache/19/10/[email protected]',

            # save the 2x resolution version
            'save: test/cache/19/10/[email protected]',
            'get_available_name: test/cache/19/10/[email protected]',
            'exists: test/cache/19/10/[email protected]'
        ]
        self.assertEqual(self.log, actions)

        with open(pjoin(settings.MEDIA_ROOT, 'test/cache/19/10/[email protected]')) as fp:
            engine = PILEngine()
            self.assertEqual(engine.get_image_size(engine.get_image(ImageFile(file_=fp))), (75, 75))
开发者ID:aalebedev,项目名称:sorl-thumbnail,代码行数:27,代码来源:tests.py

示例2: test_retina

# 需要导入模块: from sorl.thumbnail.engines.pil_engine import Engine [as 别名]
# 或者: from sorl.thumbnail.engines.pil_engine.Engine import get_image_size [as 别名]
    def test_retina(self):
        get_thumbnail(self.image, '50x50')

        actions = [
            'exists: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg',

            # save regular resolution, same as in StorageTestCase
            'open: retina.jpg',
            'save: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg',
            'get_available_name: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg',
            'exists: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg',

            # save the 1.5x resolution version
            'save: test/cache/91/bb/[email protected]',
            'get_available_name: test/cache/91/bb/[email protected]',
            'exists: test/cache/91/bb/[email protected]',

            # save the 2x resolution version
            'save: test/cache/91/bb/[email protected]',
            'get_available_name: test/cache/91/bb/[email protected]',
            'exists: test/cache/91/bb/[email protected]'
        ]
        self.assertEqual(self.log, actions)

        path = os.path.join(settings.MEDIA_ROOT,
                            'test/cache/91/bb/[email protected]')

        with open(path) as fp:
            engine = PILEngine()
            self.assertEqual(engine.get_image_size(engine.get_image(ImageFile(file_=fp))), (75, 75))
开发者ID:DeadWisdom,项目名称:sorl-thumbnail,代码行数:32,代码来源:test_alternative_resolutions.py


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