html2img

html2img is a small python script for grabbing web pages as images. To grab web.mit.edu, at a natural size for the page:

html2img1.py --url=http://web.mit.edu --output=mit.png

To grab Mission Motors web page, forcing height to 1024:

html2img1.py --url="http://www.ridemission.com" --output="emission.png" --yscale=false --height=1024

Requirements:

Download

Here!

Usage details

Main options:

  --url=LOCATION
  --output=filename

html2img has two ways of picking image size. By default it will pick the smallest image that will fit the web page, with bounds set by minwidth, maxwidth, minheight, and maxheight. Alternatively, you can specify a width and height. The specific algorithm is:

Assume width=width, height=height. If xscale is true, scale the width until there is no horizontal scrollbar necessary. if yscale is true, scale the height until there is no vertical scrollbar necessary.

Parameters:

  --height=NNN (default 400)
  --width=NNN (default 400)
  --minwidth=NNN (default 1)
  --maxwidth=NNN (default 4096)
  --minheight=NNN (default 1)
  --maxheight=NNN (default 16384)
  --xscale=true/[anything else]
  --yscale=true/[anything else]

For some pages, you may need to mess with this a little bit -- there isn't always a natural resolution.

Known Bugs

Unknown Bugs

License

License: GPLv2.0 or later, or LGPLv3.0 or later. I like GPLv3, and so I would feel bad if someone recopyrighted this as GPLv2.0 only (though I don't think I have any way to stop you if you decide to do that).

FAQ

Why does the filename html2img1.py have a 1 at the end?

The command line options are obnoxiously verbose. I'd like to be able to change that in future versions without breaking existing scripts. The version number will allow future (more sane) versions to coexist with the current version.

Isn't there a competing utility with the same name?

I couldn't find one. If you know of one, let me know. I found a bunch of spam sites with randomly generated filenames, and I found one project that was a dead link. If you know of one, let me know, and I'll rename it.


Copyright © 2010. Piotr Mitros. All rights reserved.