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


Python Image.rotate方法代码示例

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


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

示例1: get_image

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import rotate [as 别名]
    def get_image(self, source):
        blob = Blob()
        blob.update(source.read())
        image = Image(blob)
        orientation = image.orientation()

        if orientation in (OrientationType.UndefinedOrientation,
            OrientationType.TopLeftOrientation):
            pass
        elif orientation == OrientationType.TopRightOrientation:
            image.flop()
        elif orientation == OrientationType.BottomRightOrientation:
            image.rotate(180.)
        elif orientation == OrientationType.BottomLeftOrientation:
            image.flip()
        elif orientation == OrientationType.LeftTopOrientation:
            image.rotate(90.).flip()
        elif orientation == OrientationType.RightTopOrientation:
            image.rotate(90.)
        elif orientation == OrientationType.RightBottomOrientation:
            image.rotate(90.).flop()
        elif orientation == OrientationType.LeftBottomOrientation:
            image.rotate(270.)

        image.orientation(OrientationType.TopLeftOrientation)

        return image
开发者ID:vad,项目名称:sorl-thumbnail,代码行数:29,代码来源:pgmagick_engine.py

示例2: generate

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import rotate [as 别名]
    def generate(self, source_path, small_thumb_path, large_thumb_path):
        img = Image(source_path)

        width = img.size().width()
        height = img.size().height()

        # Detect if we need to rotate the image by reading EXIF data
        orientation = 0
        if img.attribute("EXIF:Orientation") != "unknown":
            try:
                orientation = int(img.attribute("EXIF:Orientation"))
            except ValueError:
                print ("Invalid EXIF orientation, using default")

        # Detect if we need to resize the large thumbnail
        if width > LARGE_MAX_WIDTH:
            height = int((float(height) / width) * LARGE_MAX_WIDTH)
            width = LARGE_MAX_WIDTH
        elif height > LARGE_MAX_HEIGHT:
            width = int((float(width) / height) * LARGE_MAX_HEIGHT)
            height = LARGE_MAX_HEIGHT

        # Rescale the large thumbnail if dimensions doesn't match
        if width != img.size().width() or height != img.size().height():
            img.sample("!%sx%s" % (width, height))

        # Rotate the image if needed
        if orientation == 6:
            img.rotate(90)
        elif orientation == 8:
            img.rotate(-90)

        self.write_image(img, large_thumb_path)

        # Crop the small thumbnail and then resize it to the correct size
        img.crop("%sx%s" % (min(width, height), min(width, height)))
        img.sample("%sx%s" % (SMALL_WIDTH_AND_HEIGHT, SMALL_WIDTH_AND_HEIGHT))

        self.write_image(img, small_thumb_path)
开发者ID:buxxi,项目名称:scripts,代码行数:41,代码来源:directory_thumbnails.py

示例3: rotate

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import rotate [as 别名]
 def rotate(srcFile="", destFile="", rotate=90):
     img =Image( srcFile )
     img.rotate( int(rotate) )
     img.profile("*",Blob())
     img.write( destFile )
     return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:8,代码来源:myGraphicsMagick.py

示例4: Blob

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import rotate [as 别名]
parser.add_argument('infiles', nargs='*', type=argparse.FileType('r'), default=sys.stdin)
parser.add_argument('-o', default="split%d.pnm")
args = parser.parse_args()

number = 0
outpattern = args.o

for file in args.infiles:
  blob = Blob(file.read())
  file.close()

  # upper half
  im = Image(blob)
  width = im.columns()
  height = im.rows() // 2
  geo = Geometry( '%dx%d' % (width,height) )
  im.crop(geo)
  im.write(outpattern % number)

  # lower half
  im = Image(blob)
  width = im.columns()
  height = im.rows() // 2
  geo = Geometry( '%dx%d+0+%d' % (width,height,height) )
  im.crop(geo)
  im.rotate(180)
  im.write(outpattern % (number + 1))

  number += 2

开发者ID:thkoch2001,项目名称:general-config,代码行数:31,代码来源:splitadfduplex.py


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