• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python transformer.Transformer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _prepare_engine

    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,代码行数:7,代码来源:transformer_vows.py


示例2: test_can_fit_in

    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,代码行数:7,代码来源:test_transformer.py


示例3: topic

 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,代码行数:11,代码来源:transformer_vows.py


示例4: test_can_resize_images_with_detection_error

 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,代码行数:11,代码来源:test_transformer.py


示例5: assert_fit_in_resize

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,代码行数:13,代码来源:test_transformer.py


示例6: topic

        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,代码行数:14,代码来源:transformer_vows.py


示例7: topic

        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,代码行数:14,代码来源:transformer_vows.py


示例8: test_can_resize_images_with_detection_error_not_ignoring_it

    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,代码行数:14,代码来源:test_transformer.py


示例9: test_invalid_crop

    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,代码行数:15,代码来源:test_transformer.py


示例10: test_get_target_dimensions

    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,代码行数:15,代码来源:test_transformer.py


示例11: test_can_resize_with_stretch

 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,代码行数:15,代码来源:test_transformer.py


示例12: test_invalid_crop

    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,代码行数:15,代码来源:test_transformer.py


示例13: test_can_transform_with_flip

    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,代码行数:16,代码来源:test_transformer.py


示例14: test_can_fit_in

    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,代码行数:16,代码来源:test_transformer.py


示例15: test_can_transform_meta_with_orientation

    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,代码行数:17,代码来源:test_transformer.py


示例16: test_can_extract_cover

    def test_can_extract_cover(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()
        ctx.request.filters = 'cover()'
        ctx.request.image = 'some.gif'
        ctx.request.extension = 'GIF'
        ctx.request.engine.extension = '.gif'
        ctx.config.USE_GIFSICLE_ENGINE = True

        engine = ctx.modules.engine

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


示例17: assert_proper_operations

def assert_proper_operations(data):
    trans = Transformer(data.to_context())
    trans.transform()

    assert data.has_cropped_properly(), data.crop_error_message
    assert data.has_resized_properly(), data.resize_error_message
开发者ID:torkil,项目名称:thumbor,代码行数:6,代码来源:test_transformer.py


示例18: _get_engine

    def _get_engine(self, topic):
        context = topic[0].to_context()
        trans = Transformer(context)
        trans.transform()

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


示例19: test_can_resize_images

 def test_can_resize_images(self):
     for item in TESTITEMS:
         context = item.to_context()
         trans = Transformer(context)
         trans.transform(lambda: None)
         self.validate_resize(item)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:6,代码来源:test_transformer.py


示例20: test_can_resize_images_with_detectors

 def test_can_resize_images_with_detectors(self):
     for item in TESTITEMS:
         context = item.to_context(detectors=[MockSyncDetector])
         trans = Transformer(context)
         trans.transform(lambda: None)
         self.validate_resize(item)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:6,代码来源:test_transformer.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python url.Url类代码示例发布时间:2022-05-27
下一篇:
Python redis_storage.Storage类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap