我正在尝试将imgkit图像转换为PIL映像来修改它。当我尝试使用一个文件时,imgkit成功地将html转换成图像。当我使用BytesIO并尝试转换为PIL映像时,我会得到一个错误。
这是我的代码:
img = imgkit.from_string(template.render(a=elements, r=range(len(elements))), False, config=config)
bytesImg = BytesIO(img)
bytesImg.seek(0)
image = Image.open(bytesImg) #error herePIL.UnidentifiedImageError:无法在0x102082680>识别图像文件<_io.BytesIO对象
我已经见过这和这了。我是不正确地将imgkit映像转换为字节,还是有其他错误?
使用枕头8.1 Python 3.9和imgkit 1.0.2
发布于 2021-01-28 09:11:38
imgkit将html转换为pdf,因为配置变量被搞乱了。
使用
which wkhtmltoimage查找wkhtmltoimage的路径并设置
config = imgkit.config(wkhtmltoimage="path found")https://stackoverflow.com/questions/65933474
复制相似问题