将html转换为图像? [英] Convert html to an image?

查看:118
本文介绍了将html转换为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在python中将下面的html转换为image(png)。

I want to convert following html to image (png) in python.

<html>
    <b>Bold text</b>
</html>

这个html当然是一个例子。

This html is, of course, an example.

我尝试过'比萨',但它将html转换为pdf,而不是图像。
我可以将html转换为pdf,然后将PDF转换为PNG,
但我想知道是否有任何直接解决方案(即html到PNG)。
任何内置或外部模块都可以很好地工作。

I have tried 'pisa' but it converts html to pdf, not to image. I can convert html to pdf and then convert pdf to png, but i was wondering if there is any direct solution(i.e html to png). Any built-in or external module will work nicely.

如果可以在Graphicsmagick或Imagemagick中完成,那么它将是完美的。

if this can be done in Graphicsmagick or Imagemagick, then it will be perfect.

推荐答案

webkit2png。原始版本仅支持OSX,但幸运的是有一个跨平台的分支:
https://github.com/AdamN/python-webkit2png

webkit2png. The original version is OSX-only, but luckily there is a cross-platform fork: https://github.com/AdamN/python-webkit2png

这篇关于将html转换为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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