如何在不重新缩放的情况下在Reportlab中设置图像的最大大小?
发布时间:2020-12-20 11:28:01 所属栏目:Python 来源:网络整理
导读:我正在尝试使用Reportlab生成pdf.这很容易接受.我有一个像下面那样的函数返回图像,我只是将它添加到文档中. def create_logo(bsolute_path): image = Image(absolute_path) image.drawHeight = 1 * inch image.drawWidth = 2 * inch return [image] 它有效但
我正在尝试使用Reportlab生成pdf.这很容易接受.我有一个像下面那样的函数返回图像,我只是将它添加到文档中.
def create_logo(bsolute_path): image = Image(absolute_path) image.drawHeight = 1 * inch image.drawWidth = 2 * inch return [image] 它有效但不是我想要的.我遇到的问题是它重新调整了我的图像. 我基本上想要的是只指定最大宽度和高度,如果图像太大,让reportlab调整大小(不重新缩放). 这可以在Reportlab中完成,还是我自己应该这样做? 谢谢! 解决方法
我也发现了这个:
Image aspect ratio using Reportlab in Python 但最后我用这个方法: def create_logo(absolute_path): image = Image(absolute_path) image._restrictSize(2 * inch,1 * inch) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |