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


Python Image.FLIP_TOP_BOTTOM属性代码示例

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


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

示例1: __call__

# 需要导入模块: import Image [as 别名]
# 或者: from Image import FLIP_TOP_BOTTOM [as 别名]
def __call__(self, img):
        '''
        Args:
            img (PIL Image): Image to be flipped.
        '''
        if random.random() < self.p:
            if isinstance(img, np.ndarray):
                return img[:,:,::-1,:]
            elif isinstance(img, Image.Image):
                return img.transpose(Image.FLIP_TOP_BOTTOM)
        return img 
开发者ID:Kashu7100,项目名称:Qualia2.0,代码行数:13,代码来源:transforms.py

示例2: save

# 需要导入模块: import Image [as 别名]
# 或者: from Image import FLIP_TOP_BOTTOM [as 别名]
def save(self,file=None):
    self.w.update()      # force image on screen to be current before saving it
        
    pstring = glReadPixels(0,0,self.xpixels,self.ypixels,
                           GL_RGBA,GL_UNSIGNED_BYTE)
    snapshot = Image.fromstring("RGBA",(self.xpixels,self.ypixels),pstring)
    snapshot = snapshot.transpose(Image.FLIP_TOP_BOTTOM)

    if not file: file = self.file
    snapshot.save(file + ".png")

  # -------------------------------------------------------------------- 
开发者ID:lammps,项目名称:pizza,代码行数:14,代码来源:gl.py

示例3: getmask2

# 需要导入模块: import Image [as 别名]
# 或者: from Image import FLIP_TOP_BOTTOM [as 别名]
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. 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:16,代码来源:ImageFont.py

示例4: flip

# 需要导入模块: import Image [as 别名]
# 或者: from Image import FLIP_TOP_BOTTOM [as 别名]
def flip(image):
    "Flip image vertically"
    return image.transpose(Image.FLIP_TOP_BOTTOM)

##
# Convert the image to grayscale.
#
# @param image The image to convert.
# @return An image. 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:11,代码来源:ImageOps.py

示例5: save

# 需要导入模块: import Image [as 别名]
# 或者: from Image import FLIP_TOP_BOTTOM [as 别名]
def save(filename, width, height, fmt, pixels, flipped=False):
        image = PILImage.fromstring(fmt.upper(), (width, height), pixels)
        if flipped:
            image = image.transpose(PILImage.FLIP_TOP_BOTTOM)
        image.save(filename)
        return True


# register 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:11,代码来源:img_pil.py

示例6: _CorrectOrientation

# 需要导入模块: import Image [as 别名]
# 或者: from Image import FLIP_TOP_BOTTOM [as 别名]
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 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:37,代码来源:images_stub.py

示例7: decode

# 需要导入模块: import Image [as 别名]
# 或者: from Image import FLIP_TOP_BOTTOM [as 别名]
def decode(self, file, filename):
        try:
            image = Image.open(file)
        except Exception as e:
            raise ImageDecodeException(
                'PIL cannot read %r: %s' % (filename or file, e))

        try:
            image = image.transpose(Image.FLIP_TOP_BOTTOM)
        except Exception as e:
            raise ImageDecodeException('PIL failed to transpose %r: %s' % (filename or file, e))

        # Convert bitmap and palette images to component
        if image.mode in ('1', 'P'):
            image = image.convert()

        if image.mode not in ('L', 'LA', 'RGB', 'RGBA'):
            raise ImageDecodeException('Unsupported mode "%s"' % image.mode)
        width, height = image.size

        # tostring is deprecated, replaced by tobytes in Pillow (PIL fork)
        # (1.1.7) PIL still uses it
        image_data_fn = getattr(image, "tobytes", getattr(image, "tostring"))
        return ImageData(width, height, image.mode, image_data_fn())

    # def decode_animation(self, file, filename):
    #     try:
    #         image = Image.open(file)
    #     except Exception as e:
    #         raise ImageDecodeException('PIL cannot read %r: %s' % (filename or file, e))
    #
    #     frames = []
    #
    #     for image in ImageSequence.Iterator(image):
    #         try:
    #             image = image.transpose(Image.FLIP_TOP_BOTTOM)
    #         except Exception as e:
    #             raise ImageDecodeException('PIL failed to transpose %r: %s' % (filename or file, e))
    #
    #         # Convert bitmap and palette images to component
    #         if image.mode in ('1', 'P'):
    #             image = image.convert()
    #
    #         if image.mode not in ('L', 'LA', 'RGB', 'RGBA'):
    #             raise ImageDecodeException('Unsupported mode "%s"' % image.mode)
    #
    #         duration = None if image.info['duration'] == 0 else image.info['duration']
    #         # Follow Firefox/Mac behaviour: use 100ms delay for any delay less than 10ms.
    #         if duration <= 10:
    #             duration = 100
    #
    #         frames.append(AnimationFrame(ImageData(*image.size, image.mode, image.tobytes()), duration / 1000))
    #
    #     return Animation(frames) 
开发者ID:pyglet,项目名称:pyglet,代码行数:56,代码来源:pil.py


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