本文整理汇总了Python中PIL.PILLOW_VERSION属性的典型用法代码示例。如果您正苦于以下问题:Python PIL.PILLOW_VERSION属性的具体用法?Python PIL.PILLOW_VERSION怎么用?Python PIL.PILLOW_VERSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类PIL
的用法示例。
在下文中一共展示了PIL.PILLOW_VERSION属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: affine
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import PILLOW_VERSION [as 别名]
def affine(img, angle, translate, scale, shear, resample=0, fillcolor=None):
"""Apply affine transformation on the image keeping image center invariant
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): rotation angle in degrees between -180 and 180, clockwise direction.
translate (list or tuple of integers): horizontal and vertical translations (post-rotation translation)
scale (float): overall scale
shear (float): shear angle value in degrees between -180 to 180, clockwise direction.
resample (``PIL.Image.NEAREST`` or ``PIL.Image.BILINEAR`` or ``PIL.Image.BICUBIC``, optional):
An optional resampling filter.
See `filters`_ for more information.
If omitted, or if the image has mode "1" or "P", it is set to ``PIL.Image.NEAREST``.
fillcolor (int): Optional fill color for the area outside the transform in the output image. (Pillow>=5.0.0)
"""
if not _is_pil_image(img):
raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
assert isinstance(translate, (tuple, list)) and len(translate) == 2, \
"Argument translate should be a list or tuple of length 2"
assert scale > 0.0, "Argument scale should be positive"
output_size = img.size
center = (img.size[0] * 0.5 + 0.5, img.size[1] * 0.5 + 0.5)
matrix = _get_inverse_affine_matrix(center, angle, translate, scale, shear)
kwargs = {"fillcolor": fillcolor} if PILLOW_VERSION[0] == '5' else {}
return img.transform(output_size, Image.AFFINE, matrix, resample, **kwargs)
示例2: check17_pillow
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import PILLOW_VERSION [as 别名]
def check17_pillow(self):
'''PILLOW
Allows Production of jpg images from non-jpg images in LaTeX documents
#TODO prculley mentions that : And PIL (Pillow) is also used by the
main Gramps ([]narrativeweb and []other reports for image cropping)
as well as [x]editexifmetadata and the
new [x]latexdoc type addons (genealogytree).
#TODO add check for PILLOW to "gramps -v" section
https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/plugins/docgen/latexdoc.py
'''
#self.append_text("\n")
# Start check
try:
import PIL
# from PIL import Image
try:
pil_ver = PIL.__version__
except Exception:
try:
pil_ver = str(PIL.PILLOW_VERSION)
except Exception:
try:
#print(dir(PIL))
pil_ver = str(PIL.VERSION)
except Exception:
pil_ver = "Installed but does not supply version"
except ImportError:
pil_ver = "Not found"
result = "(PILLOW " + pil_ver + ")"
# End check
self.append_text(result)
示例3: affine
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import PILLOW_VERSION [as 别名]
def affine(img, label, angle, translate, scale, shear, resample=0, fillcolor=None):
"""Apply affine transformation on the image keeping image center invariant
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): rotation angle in degrees between -180 and 180, clockwise direction.
translate (list or tuple of integers): horizontal and vertical translations(post-rotation translation)
scale (float): overall scale
shear (float): shear angle value in degrees between -180 to 180, clockwise direction.
resample (``PIL.Image.NEAREST`` or ``PIL.Image.BILINEAR`` or ``PIL.Image.BICUBIC``, optional):
An optional resampling filter.
See `filters`_ for more information.
If omitted, or if the image has mode "1" or "P", it is set to ``PIL.Image.NEAREST``.
fillcolor (int): Optional fill color for the area outside the transform in the output image. (Pillow>=5.0.0)
"""
if not _is_pil_image(img):
raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
assert isinstance(translate, (tuple, list)) and len(translate) == 2, \
"Argument translate should be a list or tuple of length 2"
assert scale > 0.0, "Argument scale should be positive"
output_size = img.size
center = (img.size[0] * 0.5 + 0.5, img.size[1] * 0.5 + 0.5)
matrix = _get_inverse_affine_matrix(center, angle, translate, scale, shear)
kwargs = {"fillcolor": fillcolor} if PILLOW_VERSION[0] == '5' else {}
return img.transform(output_size, Image.AFFINE, matrix, resample, **kwargs),\
label.transform(output_size, Image.AFFINE, matrix, resample, **kwargs)