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


Python FocalPoint.from_alignment方法代码示例

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


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

示例1: adjust_focal_points

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
    def adjust_focal_points(self):
        source_width, source_height = self.engine.size

        self.focal_points = None

        if self.context.request.focal_points:
            if self.context.request.should_crop:
                self.focal_points = []
                crop = self.context.request.crop
                for point in self.context.request.focal_points:
                    if point.x < crop['left'] or point.x > crop['right'] or point.y < crop['top'] or point.y > crop['bottom']:
                        continue
                    point.x -= crop['left'] or 0
                    point.y -= crop['top'] or 0
                    self.focal_points.append(point)
            else:
                self.focal_points = self.context.request.focal_points

        if not self.focal_points:
            self.focal_points = [
                FocalPoint.from_alignment(self.context.request.halign,
                                          self.context.request.valign,
                                          source_width,
                                          source_height)
            ]

        self.engine.focus(self.focal_points)
开发者ID:caeugusmao,项目名称:thumbor,代码行数:29,代码来源:transformer.py

示例2: calculate_focal_points

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
 def calculate_focal_points(self):
     if self.context['focal_points']:
         self.focal_points = self.context['focal_points']
     else:
         self.focal_points = [
             FocalPoint.from_alignment(self.context['halign'],
                                       self.context['valign'],
                                       self.source_width,
                                       self.source_height)
         ]
开发者ID:rootart,项目名称:thumbor,代码行数:12,代码来源:transformer.py

示例3: calculate_focal_points

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
    def calculate_focal_points(self):
        source_width, source_height = self.engine.size

        if self.context['focal_points']:
            self.focal_points = self.context['focal_points']
        else:
            self.focal_points = [
                FocalPoint.from_alignment(self.context['halign'],
                                          self.context['valign'],
                                          source_width,
                                          source_height)
            ]

        self.engine.focus(self.focal_points)
开发者ID:cezarsa,项目名称:thumbor,代码行数:16,代码来源:transformer.py

示例4: calculate_focal_points

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
    def calculate_focal_points(self):
        source_width, source_height = self.engine.size

        if self.context.request.focal_points:
            self.focal_points = self.context.request.focal_points
        else:
            self.focal_points = [
                FocalPoint.from_alignment(self.context.request.halign,
                                          self.context.request.valign,
                                          source_width,
                                          source_height)
            ]

        self.engine.focus(self.focal_points)
开发者ID:mikelikespie,项目名称:thumbor,代码行数:16,代码来源:transformer.py

示例5: process

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
 def process(self, canvas_width, canvas_height, size):
     try:
         self.engine.load(self.buffer, self.extension)
         width, height = self.engine.size
         new_width, new_height = calc_new_size_by_height(width, height, canvas_height)
         focal_points = StandaloneFaceDetector.features_to_focal_points(
             StandaloneFaceDetector.get_features(self.thumbor_filter.context, self.engine))
         if focal_points:
             self.resize_focal_points(focal_points, float(new_width) / width)
         else:
             focal_points.append(FocalPoint.from_alignment('center', 'top', new_width, new_height))
         self.engine.resize(new_width, new_height)
         self.engine.focus(focal_points)
         StandaloneFaceDetector.auto_crop(self.engine, focal_points, size, canvas_height)
     except Exception as err:
         logger.exception(err)
开发者ID:gi11es,项目名称:thumbor-debian,代码行数:18,代码来源:distributed_collage.py

示例6: adjust_focal_points

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
    def adjust_focal_points(self):
        source_width, source_height = self.engine.size

        self.focal_points = []

        if self.context.request.focal_points:
            crop = self.context.request.crop
            for point in self.context.request.focal_points:
                point.x -= crop['left'] or 0
                point.y -= crop['top'] or 0
                if point.x < 0 or point.x > self.target_width or \
                        point.y < 0 or point.y > self.target_height:
                    continue
                self.focal_points.append(point)

        if not self.focal_points:
            self.focal_points = [
                FocalPoint.from_alignment(self.context.request.halign,
                                          self.context.request.valign,
                                          source_width,
                                          source_height)
            ]

        self.engine.focus(self.focal_points)
开发者ID:MechanisM,项目名称:thumbor,代码行数:26,代码来源:transformer.py

示例7: test_aligned_point_bottom_right

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
 def test_aligned_point_bottom_right(self):
     point = FocalPoint.from_alignment('right', 'bottom', 300, 200)
     expect(point.x).to_equal(300)
     expect(point.y).to_equal(200)
     expect(point.weight).to_equal(1.0)
开发者ID:GDxU,项目名称:thumbor,代码行数:7,代码来源:test_point.py

示例8: test_aligned_point_top_left

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
 def test_aligned_point_top_left(self):
     point = FocalPoint.from_alignment('left', 'top', 300, 200)
     expect(point.x).to_equal(0)
     expect(point.y).to_equal(0)
     expect(point.weight).to_equal(1.0)
开发者ID:GDxU,项目名称:thumbor,代码行数:7,代码来源:test_point.py

示例9: test_aligned_point_center_middle

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
 def test_aligned_point_center_middle(self):
     point = FocalPoint.from_alignment('center', 'middle', 300, 200)
     expect(point.x).to_equal(150)
     expect(point.y).to_equal(100)
     expect(point.weight).to_equal(1.0)
开发者ID:GDxU,项目名称:thumbor,代码行数:7,代码来源:test_point.py

示例10: topic

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
 def topic(self):
     return FocalPoint.from_alignment('left', 'top', 300, 200)
开发者ID:douglas,项目名称:thumbor,代码行数:4,代码来源:point_vows.py

示例11: assert_point_from_alignment

# 需要导入模块: from thumbor.point import FocalPoint [as 别名]
# 或者: from thumbor.point.FocalPoint import from_alignment [as 别名]
def assert_point_from_alignment(point):
    comp_point = FocalPoint.from_alignment(point[0], point[1], width=point[2], height=point[3])

    assert comp_point.x == point[4], "Expected x => %.2f Got x => %.2f" % (point[4], comp_point.x)
    assert comp_point.y == point[5], "Expected y => %.2f Got y => %.2f" % (point[5], comp_point.y)
    assert comp_point.weight == 1.0
开发者ID:expertise-com,项目名称:thumbor,代码行数:8,代码来源:test_focal_points.py


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