Python Image 模块,FLIP_LEFT_RIGHT 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用Image.FLIP_LEFT_RIGHT

项目:gougo    作者:amaozhao    | 项目源码 | 文件源码
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
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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
项目:CNCGToolKit    作者:cineuse    | 项目源码 | 文件源码
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.
项目:CNCGToolKit    作者:cineuse    | 项目源码 | 文件源码
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.
项目:InstagramPosting    作者:LeviParadis    | 项目源码 | 文件源码
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.
项目:InstagramPosting    作者:LeviParadis    | 项目源码 | 文件源码
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.
项目:ngx_status    作者:YoYoAdorkable    | 项目源码 | 文件源码
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.
项目:ngx_status    作者:YoYoAdorkable    | 项目源码 | 文件源码
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.