本文整理汇总了Python中reportlab.lib.utils.ImageReader.hAlign方法的典型用法代码示例。如果您正苦于以下问题:Python ImageReader.hAlign方法的具体用法?Python ImageReader.hAlign怎么用?Python ImageReader.hAlign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.lib.utils.ImageReader
的用法示例。
在下文中一共展示了ImageReader.hAlign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getImage
# 需要导入模块: from reportlab.lib.utils import ImageReader [as 别名]
# 或者: from reportlab.lib.utils.ImageReader import hAlign [as 别名]
def getImage(img_obj, scale=True, reader=False, width=max_image_width, style="", column_count=column_count, caption="", leadImage=False, hAlign=None, body_image=True):
if not leadImage and body_image and column_count == 1:
# Special case to make one column body images 66% of the page
width = 1.33*width
img_width = img_obj.width
img_height = img_obj.height
if scale and (img_width > width):
img_height = (width/img_width)*img_height
img_width = width
if hasattr(img_obj, 'data'):
if hasattr(img_obj.data, 'data'):
img_data = BytesIO(img_obj.data.data)
else:
img_data = BytesIO(img_obj.data)
elif hasattr(img_obj, '_data'):
img_data = BytesIO(img_obj._data)
else:
img_data = BytesIO('')
if reader:
img = ImageReader(img_data)
else:
if caption or leadImage:
img = ImageFigure(img_data, caption=caption, width=img_width, height=img_height, align="right", max_image_width=width, column_count=column_count)
else:
img = Image(img_data, width=img_width, height=img_height)
if style:
img.style = style
if hAlign:
img.hAlign = hAlign
elif column_count == 1:
img.hAlign = TA_LEFT
else:
img.hAlign = TA_CENTER
return img