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


Python Transformer.transform方法代码示例

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


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

示例1: _prepare_engine

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def _prepare_engine(self, topic, callback):
        context = topic[0].to_context()
        self.engine = context.modules.engine
        self.test_data = topic

        trans = Transformer(context)
        trans.transform(callback)
开发者ID:mikelikespie,项目名称:thumbor,代码行数:9,代码来源:transformer_vows.py

示例2: test_can_fit_in

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_can_fit_in(self):
        for item in FIT_IN_CROP_DATA:
            context = item[0].to_context()
            engine = context.modules.engine

            trans = Transformer(context)
            trans.transform(self.validate_fit_in(item, context, engine, trans))
开发者ID:expertise-com,项目名称:thumbor,代码行数:9,代码来源:test_transformer.py

示例3: topic

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
 def topic(self, callback):
     self.test_data = TestData(
         source_width=800, source_height=600,
         target_width=400, target_height=150,
         halign="center", valign="middle",
         focal_points=[],
         crop_left=0, crop_top=75, crop_right=800, crop_bottom=375
     )
     context = self.test_data.to_context(detectors=[MockErrorSyncDetector], ignore_detector_error=False)
     trans = Transformer(context)
     trans.transform(callback)
开发者ID:APSL,项目名称:thumbor,代码行数:13,代码来源:transformer_vows.py

示例4: test_can_resize_images_with_detection_error

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
 def test_can_resize_images_with_detection_error(self):
     test_data = TestData(
         source_width=800, source_height=600,
         target_width=400, target_height=150,
         halign="center", valign="middle",
         focal_points=[],
         crop_left=0, crop_top=75, crop_right=800, crop_bottom=375
     )
     context = test_data.to_context(detectors=[MockErrorSyncDetector], ignore_detector_error=True)
     trans = Transformer(context)
     trans.transform(self.validate_resize(test_data))
开发者ID:expertise-com,项目名称:thumbor,代码行数:13,代码来源:test_transformer.py

示例5: assert_fit_in_resize

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
def assert_fit_in_resize(data):
    data, expectations = data

    trans = Transformer(data.to_context())
    trans.transform()

    assert not data.engine.calls['crop']

    assert data.engine.calls['resize']
    assert len(data.engine.calls['resize']) == 1

    assert data.engine.calls['resize'][0]['width'] == expectations[0]
    assert data.engine.calls['resize'][0]['height'] == expectations[1]
开发者ID:torkil,项目名称:thumbor,代码行数:15,代码来源:test_transformer.py

示例6: topic

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
        def topic(self):
            data = TestData(
                        source_width=800, source_height=600,
                        target_width=-800, target_height=-600,
                        halign="right", valign="top",
                        focal_points=[],
                        crop_left=None, crop_top=None, crop_right=None, crop_bottom=None
                    )

            ctx = data.to_context()
            trans = Transformer(ctx)
            trans.transform()

            return ctx['engine']
开发者ID:cezarsa,项目名称:thumbor,代码行数:16,代码来源:transformer_vows.py

示例7: topic

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
        def topic(self, callback):
            data = TestData(
                        source_width=800, source_height=600,
                        target_width=-800, target_height=-600,
                        halign="right", valign="top",
                        focal_points=[],
                        crop_left=None, crop_top=None, crop_right=None, crop_bottom=None
                    )

            ctx = data.to_context()
            self.engine = ctx.modules.engine

            trans = Transformer(ctx)
            trans.transform(callback)
开发者ID:mikelikespie,项目名称:thumbor,代码行数:16,代码来源:transformer_vows.py

示例8: test_can_resize_images_with_detection_error_not_ignoring_it

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_can_resize_images_with_detection_error_not_ignoring_it(self):
        test_data = TestData(
            source_width=800, source_height=600,
            target_width=400, target_height=150,
            halign="center", valign="middle",
            focal_points=[],
            crop_left=0, crop_top=75, crop_right=800, crop_bottom=375
        )
        context = test_data.to_context(detectors=[MockErrorSyncDetector], ignore_detector_error=False)
        trans = Transformer(context)

        trans.transform(lambda: None)

        expect(test_data.engine.calls['resize']).to_length(0)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:16,代码来源:test_transformer.py

示例9: test_invalid_crop

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_invalid_crop(self):
        data = TestData(
            source_width=800, source_height=600,
            target_width=800, target_height=600,
            halign="right", valign="top",
            focal_points=[],
            crop_left=200, crop_top=0, crop_right=100, crop_bottom=100
        )

        ctx = data.to_context()
        engine = ctx.modules.engine

        trans = Transformer(ctx)
        trans.transform(lambda: None)
        expect(engine.calls['crop']).to_be_empty()
开发者ID:caeugusmao,项目名称:thumbor,代码行数:17,代码来源:test_transformer.py

示例10: test_get_target_dimensions

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_get_target_dimensions(self):
        data = TestData(
            source_width=800, source_height=600,
            target_width=600, target_height=400,
            halign="right", valign="top",
            focal_points=[],
            crop_left=200, crop_top=0, crop_right=100, crop_bottom=100
        )

        ctx = data.to_context()
        trans = Transformer(ctx)
        dimensions = trans.get_target_dimensions()
        expect(dimensions).to_equal((600, 400))
        trans.transform(lambda: 1)
        expect(dimensions).to_equal((600, 400))
开发者ID:caeugusmao,项目名称:thumbor,代码行数:17,代码来源:test_transformer.py

示例11: test_can_resize_with_stretch

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
 def test_can_resize_with_stretch():
     data = TestData(
         source_width=800, source_height=600,
         target_width=800, target_height=200,
         halign="right", valign="top",
         focal_points=[],
         crop_left=None, crop_top=None, crop_right=None, crop_bottom=None,
         stretch=True
     )
     ctx = data.to_context()
     engine = ctx.modules.engine
     trans = Transformer(ctx)
     trans.transform(lambda: None)
     expect(engine.calls['resize']).to_equal([{'width': 800, 'height': 200}])
     expect(engine.calls['crop']).to_be_empty()
开发者ID:caeugusmao,项目名称:thumbor,代码行数:17,代码来源:test_transformer.py

示例12: test_invalid_crop

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_invalid_crop(self):
        data = TestData(
            source_width=800, source_height=600,
            target_width=800, target_height=600,
            halign="right", valign="top",
            focal_points=[],
            crop_left=200, crop_top=0, crop_right=100, crop_bottom=100
        )

        ctx = data.to_context()
        engine = ctx.modules.engine

        trans = Transformer(ctx)
        trans.transform(self.handle_invalid_crop(engine))
        expect(self.has_handled).to_be_true()
开发者ID:expertise-com,项目名称:thumbor,代码行数:17,代码来源:test_transformer.py

示例13: test_can_transform_with_flip

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_can_transform_with_flip(self):
        data = TestData(
            source_width=800, source_height=600,
            target_width=-800, target_height=-600,
            halign="right", valign="top",
            focal_points=[],
            crop_left=None, crop_top=None, crop_right=None, crop_bottom=None
        )

        ctx = data.to_context()
        engine = ctx.modules.engine

        trans = Transformer(ctx)
        trans.transform(lambda: None)
        expect(engine.calls['horizontal_flip']).to_equal(1)
        expect(engine.calls['vertical_flip']).to_equal(1)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:18,代码来源:test_transformer.py

示例14: test_can_fit_in

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_can_fit_in(self):
        for (test_data, (width, height, should_resize)) in FIT_IN_CROP_DATA:
            context = test_data.to_context()
            engine = context.modules.engine

            trans = Transformer(context)
            trans.transform(lambda: None)

            expect(engine.calls['crop']).to_be_empty()

            if should_resize:
                expect(engine.calls['resize']).to_length(1)
                expect(engine.calls['resize'][0]['width']).to_equal(width)
                expect(engine.calls['resize'][0]['height']).to_equal(height)
            else:
                expect(engine.calls['resize']).to_be_empty()
开发者ID:caeugusmao,项目名称:thumbor,代码行数:18,代码来源:test_transformer.py

示例15: test_can_transform_meta_with_orientation

# 需要导入模块: from thumbor.transformer import Transformer [as 别名]
# 或者: from thumbor.transformer.Transformer import transform [as 别名]
    def test_can_transform_meta_with_orientation(self):
        data = TestData(
            source_width=800, source_height=600,
            target_width=100, target_height=100,
            halign="right", valign="top",
            focal_points=[],
            crop_left=None, crop_top=None, crop_right=None, crop_bottom=None,
            meta=True
        )

        ctx = data.to_context()
        ctx.config.RESPECT_ORIENTATION = True
        engine = ctx.modules.engine

        trans = Transformer(ctx)
        trans.transform(lambda: None)
        expect(engine.calls['reorientate']).to_equal(1)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:19,代码来源:test_transformer.py


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