reportlab库的ImageReader方法不起作用

问题描述 投票:0回答:1

reportlab ImageReader('url')的PIL库不起作用。我的环境:Python 3.7.6,Pillow 7.0.0,Reportlab 3.5.32(我也尝试过不同版本的PIL和reportlab ...相同的错误)

img = ImageReader('https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png')

我的错误

Cannot open resource "https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
fileName='https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png' identity=[ImageReader@0x119474090 filename='https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png']
python python-imaging-library reportlab
1个回答
0
投票
已解决...使用reportlab表中的URL图像解决方案:

from PIL import Image as pillowImage from django.core.files.storage import default_storage from io import BytesIO from reportlab.platypus import Image cloud_image = default_storage.open('url') # using s3Storage img = pillowImage.open(cloud_image) img_byte_arr = BytesIO() img.save(img_byte_arr, format=img.format) result = Image(img_byte_arr, w * cm, h * cm) .... data1 = [[result]] t1 = Table(data1, colWidths=(9 * cm)) t1.setStyle(TableStyle([('VALIGN', (0, 0), (-1, -1), 'LEFT'),])) t1.hAlign = 'LEFT' story.append(t1) ...

© www.soinside.com 2019 - 2024. All rights reserved.