使用Jinja2将png图像嵌入到html文件中 [英] Embed png image in html file using Jinja2

查看:963
本文介绍了使用Jinja2将png图像嵌入到html文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Jinja2将html报告创建为单个html文件。我希望将公司徽标包含在html文件中而不是链接到它;通过这种方式,即使阅读报告的人离线,也会显示徽标。这可以使用Jinja2自动完成吗?如果没有,我该如何在html中手动嵌入png图像?

解决方案

在Google上寻找Base64编码器href =http://www.opinionatedgeek.com/dotnet/tools/base64encode/ =noreferrer> http://www.opinionatedgeek.com/dotnet/tools/base64encode/ )。之后,您可以插入

 < img src =data:image / png; base64,BASE64_ENCODED_DATA> 

放置徽标:


I'm using Jinja2 to create html reports as a single html file. I would like to include the company logo inside the html file rather than link to it; in this way the logo is displayed even if the person reading the report is offline. Can this be automatically done using Jinja2? If not how can I embed a png image in the html manually?

解决方案

look for a Base64 encoder on Google (e.g. http://www.opinionatedgeek.com/dotnet/tools/base64encode/). After that you can insert

<img src="data:image/png;base64,BASE64_ENCODED_DATA">

in place for the logo :)

这篇关于使用Jinja2将png图像嵌入到html文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆