May 26, 2018

Python wrapper to convert html to image

Python 2 and 3 wrapper for wkhtmltoimage utility to convert HTML to IMG using Webkit.

Simple example

import imgkit

imgkit.from_url’http//’, ‘out.jpg’ imgkit.from_file’test.html’, ‘out.jpg’ imgkit.from_string’Hello!’, ‘out.jpg’

You can pass a list with multiple URLs or files

imgkit.from_url[‘’, ‘’, ‘’], ‘out.jpg’ imgkit.from_file[‘file1.html’, ‘file2.html’], ‘out.jpg’

Also you can pass an opened file

with open’file.html’ as f imgkit.from_filef, ‘out.jpg’

WWW https//