Ubuntu Linux: How to Convert from HTML to JPG

Here is an easy way to convert from HTML to JPG. Actually, I’m converting the HTML to PDF and then from PDF to JPG.
First, install the following packages:
sudo apt-get install python-pisa imagemagick python-imaging
Then simply:
xhtml2pdf report.html
convert report.pdf report.jpg
Note: if you receive an error message in python “AttributeError: ‘NoneType’ object has no attribute ‘bands’” while trying to use the xhtml2pdf command, then you will need to apply this patch: http://hg.effbot.org/pil-2009-raclette/changeset/fb7ce579f5f9
In other words, edit Image.py and move line 1501 self.load()
to 1497, just before the if self.im.bands == 1:
Comments