【发布时间】:2021-08-12 09:29:34
【问题描述】:
我使用python模块html2image将html转成图片,但是由于图片大小固定,html被打断或者截断,出现空白。有没有办法使用 Python 解决这个问题? (我使用聊天导出器生成html代码)
@commands.command("savemsg")
async def savemsg(self, ctx, msgid, *, add_css=None):
msglist = await ctx.channel.fetch_message(msgid)
transcript = await chat_exporter.raw_export(ctx.channel, [msglist], "Asia/Seoul")
if transcript is None:
return
f = open("savemsg.html", 'wb')
f.write(transcript.encode())
f.close()
with open('savemsg.html') as f:
hti.screenshot(html_str=f.read(), save_as='output.png', css_str=add_css)
await ctx.send(content="Output", file=discord.File("output.png"))
返回https://cdn.discordapp.com/attachments/833899986805719040/846029096584216626/outr.png
【问题讨论】:
标签: python html image discord python-imaging-library