本文整理匯總了Python中PIL.Image.ROTATE_90屬性的典型用法代碼示例。如果您正苦於以下問題:Python Image.ROTATE_90屬性的具體用法?Python Image.ROTATE_90怎麽用?Python Image.ROTATE_90使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類PIL.Image
的用法示例。
在下文中一共展示了Image.ROTATE_90屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_channels_order
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def test_channels_order(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
# Reverse channels by splitting and using table
self.assert_image_equal(
Image.merge('RGB', im.split()[::-1]),
im._new(im.im.color_lut_3d('RGB', Image.LINEAR,
3, 2, 2, 2, [
0, 0, 0, 0, 0, 1,
0, 1, 0, 0, 1, 1,
1, 0, 0, 1, 0, 1,
1, 1, 0, 1, 1, 1,
])))
示例2: test_g4_write
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def test_g4_write(self):
"""Checking to see that the saved image is the same as what we wrote"""
test_file = "Tests/images/hopper_g4_500.tif"
orig = Image.open(test_file)
out = self.tempfile("temp.tif")
rot = orig.transpose(Image.ROTATE_90)
self.assertEqual(rot.size, (500, 500))
rot.save(out)
reread = Image.open(out)
self.assertEqual(reread.size, (500, 500))
self._assert_noerr(reread)
self.assert_image_equal(reread, rot)
self.assertEqual(reread.info['compression'], 'group4')
self.assertEqual(reread.info['compression'], orig.info['compression'])
self.assertNotEqual(orig.tobytes(), reread.tobytes())
示例3: __init__
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def __init__(self, config, comm, CameraModule):
super().__init__()
self._comm = comm
self._cfg = config
self._cam = CameraModule
self._cap = None
self._pic_dims = None
self._is_preview = self._cfg.getBool('Photobooth', 'show_preview')
self._is_keep_pictures = self._cfg.getBool('Storage', 'keep_pictures')
rot_vals = {0: None, 90: Image.ROTATE_90, 180: Image.ROTATE_180,
270: Image.ROTATE_270}
self._rotation = rot_vals[self._cfg.getInt('Camera', 'rotation')]
示例4: rotate_image
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def rotate_image(imagedata, clockwise = True):
"""
Rotate an image.
clockwise: Rotate 90 degrees clockwise, if false rotates anticlockwise
"""
try:
inputd = asm3.utils.bytesio(imagedata)
im = Image.open(inputd)
if clockwise:
im = im.transpose(Image.ROTATE_270)
else:
im = im.transpose(Image.ROTATE_90)
output = asm3.utils.bytesio()
im.save(output, "JPEG")
rotated_data = output.getvalue()
output.close()
return rotated_data
except Exception as err:
asm3.al.error("failed rotating image: %s" % str(err), "media.rotate_image")
return imagedata
示例5: get_tta_patterns
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def get_tta_patterns(src, n):
src_lr = src.transpose(Image.FLIP_LEFT_RIGHT)
patterns = [
[src, None],
[src.transpose(Image.ROTATE_90), inv(-90)],
[src.transpose(Image.ROTATE_180), inv(-180)],
[src.transpose(Image.ROTATE_270), inv(-270)],
[src_lr, inv(0, True)],
[src_lr.transpose(Image.ROTATE_90), inv(-90, True)],
[src_lr.transpose(Image.ROTATE_180), inv(-180, True)],
[src_lr.transpose(Image.ROTATE_270), inv(-270, True)],
]
if n == 2:
return [patterns[0], patterns[4]]
elif n == 4:
return [patterns[0], patterns[2], patterns[4], patterns[6]]
elif n == 8:
return patterns
return [patterns[0]]
示例6: eval_angle
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def eval_angle(im,detectAngle=False):
"""
估計圖片偏移角度
@@param:im
@@param:detectAngle 是否檢測文字朝向
"""
angle = 0
img = np.array(im)
if detectAngle:
angle = angle_detect(img=np.copy(img))##文字朝向檢測
if angle==90:
im = Image.fromarray(im).transpose(Image.ROTATE_90)
elif angle==180:
im = Image.fromarray(im).transpose(Image.ROTATE_180)
elif angle==270:
im = Image.fromarray(im).transpose(Image.ROTATE_270)
img = np.array(im)
return angle,img
示例7: __init__
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def __init__(self, p, degree):
"""Creates an `JointRandomRotation` instance.
Args:
p: the probability for rotating.
"""
self.p = p
methods = {90: Image.ROTATE_90, 180: Image.ROTATE_180, 270: Image.ROTATE_270}
if degree not in methods.keys():
raise NotImplementedError("We only support multiple of 90 degree rotations for now")
self.method = methods[degree]
示例8: rotate
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def rotate(self, image, target, link, contour, angle):
if angle == 0:
if link is None:
return image, target, contour
return image, target, link, contour
elif angle == 90:
image = image.transpose(Image.ROTATE_90)
target = target.transpose(Image.ROTATE_90)
link = np.rot90(link)
contour_f = self.contour_rotate(contour, 90, image.size[0], image.size[1])
elif angle == 180:
image = image.transpose(Image.ROTATE_180)
target = target.transpose(Image.ROTATE_180)
link = np.rot90(np.rot90(link))
contour_f = self.contour_rotate(contour, 180, image.size[1], image.size[0])
elif angle == 270:
image = image.transpose(Image.ROTATE_270)
target = target.transpose(Image.ROTATE_270)
link = np.rot90(np.rot90(np.rot90(link)))
contour_f = self.contour_rotate(contour, 270, image.size[0], image.size[1])
if link is None:
return image, target, contour_f
return image, target, link, contour_f
示例9: rotate
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def rotate(self, img, rot):
if rot == 0:
img_rt = img
elif rot == 90:
img_rt = img.transpose(Image.ROTATE_90)
elif rot == 180:
img_rt = img.transpose(Image.ROTATE_180)
elif rot == 270:
img_rt = img.transpose(Image.ROTATE_270)
else:
raise ValueError('Rotation angles should be in [0, 90, 180, 270]')
return img_rt
示例10: rotate_image
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def rotate_image(self):
if self.model.current_image is not None:
rotated_image = self.model.current_image.transpose(Image.ROTATE_90)
self.model.current_image.close()
self.model.current_image = None
self.display_image_on_canvas(rotated_image)
示例11: __init__
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def __init__(self, width, height, text, xtext=6, ytext=6, chars=14, font_file=None):
image = Image.new('1', (width, height), WHITE)
if font_file == None:
font_file = FONT_DEFAULT
font = ImageFont.truetype(FONT_PATH + font_file, FONT_SIZE)
draw = ImageDraw.Draw(image)
w = textwrap.TextWrapper(width=chars, break_long_words=False) #, replace_whitespace=False)
for line in text.splitlines():
for frag in w.wrap(line):
#print("Line: '%s'" % frag)
width, height = font.getsize(frag)
draw.text((xtext, ytext), frag, font=font, fill=BLACK)
ytext += height
self._image = image.transpose(Image.FLIP_LEFT_RIGHT).transpose(Image.ROTATE_90)
示例12: __init__
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def __init__(self, image, icon_file, xstart=14, ystart=14):
icon = Image.open(icon_file).convert('RGBA')
icon = icon.transpose(Image.FLIP_LEFT_RIGHT).transpose(Image.ROTATE_90)
self._name = icon_file
self._image = image
self._width, self._height = icon.size
self._image.paste(icon, (xstart, ystart, xstart+self._width, ystart+self._height), mask=icon)
示例13: test_rotate_90_deg
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def test_rotate_90_deg(self):
self._test_rotate(90, Image.ROTATE_90)
示例14: test_identities
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def test_identities(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
# Fast test with small cubes
for size in [2, 3, 5, 7, 11, 16, 17]:
self.assert_image_equal(im, im._new(
im.im.color_lut_3d('RGB', Image.LINEAR,
*self.generate_identity_table(3, size))))
# Not so fast
self.assert_image_equal(im, im._new(
im.im.color_lut_3d('RGB', Image.LINEAR,
*self.generate_identity_table(3, (2, 2, 65)))))
示例15: test_identities_4_channels
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import ROTATE_90 [as 別名]
def test_identities_4_channels(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
# Red channel copied to alpha
self.assert_image_equal(
Image.merge('RGBA', (im.split()*2)[:4]),
im._new(im.im.color_lut_3d('RGBA', Image.LINEAR,
*self.generate_identity_table(4, 17))))