python类FLIP_LEFT_RIGHT的实例源码

utils.py 文件源码 项目:gougo 作者: amaozhao 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def exif_orientation(im):
    """
    Rotate and/or flip an image to respect the image's EXIF orientation data.
    """
    try:
        exif = im._getexif()
    except Exception:
        # There are many ways that _getexif fails, we're just going to blanket
        # cover them all.
        exif = None
    if exif:
        orientation = exif.get(0x0112)
        if orientation == 2:
            im = im.transpose(Image.FLIP_LEFT_RIGHT)
        elif orientation == 3:
            im = im.rotate(180)
        elif orientation == 4:
            im = im.transpose(Image.FLIP_TOP_BOTTOM)
        elif orientation == 5:
            im = im.rotate(-90).transpose(Image.FLIP_LEFT_RIGHT)
        elif orientation == 6:
            im = im.rotate(-90)
        elif orientation == 7:
            im = im.rotate(90).transpose(Image.FLIP_LEFT_RIGHT)
        elif orientation == 8:
            im = im.rotate(90)
    return im
images_stub.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def _CorrectOrientation(self, image, orientation):
    """Use PIL to correct the image orientation based on its EXIF.

    See JEITA CP-3451 at http://www.exif.org/specifications.html,
    Exif 2.2, page 18.

    Args:
      image: source PIL.Image.Image object.
      orientation: integer in range (1,8) inclusive, corresponding the image
        orientation from EXIF.

    Returns:
      PIL.Image.Image with transforms performed on it. If no correction was
        done, it returns the input image.
    """


    if orientation == 2:
      image = image.transpose(Image.FLIP_LEFT_RIGHT)
    elif orientation == 3:
      image = image.rotate(180)
    elif orientation == 4:
      image = image.transpose(Image.FLIP_TOP_BOTTOM)
    elif orientation == 5:
      image = image.transpose(Image.FLIP_TOP_BOTTOM)
      image = image.rotate(270)
    elif orientation == 6:
      image = image.rotate(270)
    elif orientation == 7:
      image = image.transpose(Image.FLIP_LEFT_RIGHT)
      image = image.rotate(270)
    elif orientation == 8:
      image = image.rotate(90)

    return image
ImageFont.py 文件源码 项目:CNCGToolKit 作者: cineuse 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def getmask2(self, text, mode="", fill=Image.core.fill):
        size, offset = self.font.getsize(text)
        im = fill("L", size, 0)
        self.font.render(text, im.id, mode=="1")
        return im, offset

##
# Wrapper that creates a transposed font from any existing font
# object.
#
# @param font A font object.
# @param orientation An optional orientation.  If given, this should
#     be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM,
#     Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270.
ImageOps.py 文件源码 项目:CNCGToolKit 作者: cineuse 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def mirror(image):
    "Flip image horizontally"
    return image.transpose(Image.FLIP_LEFT_RIGHT)

##
# Reduce the number of bits for each colour channel.
#
# @param image The image to posterize.
# @param bits The number of bits to keep for each channel (1-8).
# @return An image.
ImageFont.py 文件源码 项目:InstagramPosting 作者: LeviParadis 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def getmask2(self, text, mode="", fill=Image.core.fill):
        size, offset = self.font.getsize(text)
        im = fill("L", size, 0)
        self.font.render(text, im.id, mode=="1")
        return im, offset

##
# Wrapper that creates a transposed font from any existing font
# object.
#
# @param font A font object.
# @param orientation An optional orientation.  If given, this should
#     be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM,
#     Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270.
ImageOps.py 文件源码 项目:InstagramPosting 作者: LeviParadis 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def mirror(image):
    "Flip image horizontally"
    return image.transpose(Image.FLIP_LEFT_RIGHT)

##
# Reduce the number of bits for each colour channel.
#
# @param image The image to posterize.
# @param bits The number of bits to keep for each channel (1-8).
# @return An image.
ImageFont.py 文件源码 项目:ngx_status 作者: YoYoAdorkable 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def getmask2(self, text, mode="", fill=Image.core.fill):
        size, offset = self.font.getsize(text)
        im = fill("L", size, 0)
        self.font.render(text, im.id, mode=="1")
        return im, offset

##
# Wrapper that creates a transposed font from any existing font
# object.
#
# @param font A font object.
# @param orientation An optional orientation.  If given, this should
#     be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM,
#     Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270.
ImageOps.py 文件源码 项目:ngx_status 作者: YoYoAdorkable 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def mirror(image):
    "Flip image horizontally"
    return image.transpose(Image.FLIP_LEFT_RIGHT)

##
# Reduce the number of bits for each colour channel.
#
# @param image The image to posterize.
# @param bits The number of bits to keep for each channel (1-8).
# @return An image.


问题


面经


文章

微信
公众号

扫码关注公众号