本文整理匯總了Python中Image.FLIP_LEFT_RIGHT屬性的典型用法代碼示例。如果您正苦於以下問題:Python Image.FLIP_LEFT_RIGHT屬性的具體用法?Python Image.FLIP_LEFT_RIGHT怎麽用?Python Image.FLIP_LEFT_RIGHT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類Image
的用法示例。
在下文中一共展示了Image.FLIP_LEFT_RIGHT屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __call__
# 需要導入模塊: import Image [as 別名]
# 或者: from Image import FLIP_LEFT_RIGHT [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_LEFT_RIGHT)
return img
示例2: getmask2
# 需要導入模塊: import Image [as 別名]
# 或者: from Image import FLIP_LEFT_RIGHT [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.
示例3: mirror
# 需要導入模塊: import Image [as 別名]
# 或者: from Image import FLIP_LEFT_RIGHT [as 別名]
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.
示例4: _CorrectOrientation
# 需要導入模塊: import Image [as 別名]
# 或者: from Image import FLIP_LEFT_RIGHT [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