def resize_images(self, story):
# replace images with resized ones fitting into the available width
W, H = (
self.width - self.lm - self.rm), self.height - self.tm - self.bm
for i, el in enumerate(story):
if el.__class__ == Image:
img = PIL.Image.open(el.filename)
h = W / img.size[0] * img.size[1]
img = Image(el.filename, width=w, height=h, kind='direct',
mask="auto", lazy=1)
story[i] = img
elif type(el) == str:
story[i] = Paragraph(el, bt) # Spacer(0, 0)
评论列表
文章目录