python 字符串转图片_在Python中将HTML字符串转换为图像

I want to convert following HTML to PNG image in Python.

Bold text

This HTML is, of course, an example.

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.

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

解决方案

webkit2png. The original version is OSX-only, but luckily there is a cross-platform fork:

https://github.com/AdamN/python-webkit2png

你可能感兴趣的:(python,字符串转图片)