MarginalHacks.com DaveSource.com
html2jpg
 

What is it?

Converts HTML pages to images (gif, jpg, png, ps, etc..)
html2jpg requires Mozilla (only some versions) to work. It's pretty kludgy. I needed a solution and couldn't find one, so maybe this is useful to you. If you have KDE, I recommend khtml2png

Features:

  • Easy to automate.
  • Attempts to remove borders, menus, scrollbars, etc..
  • Supports many image types (even postscript!)
  • Very kludgy and unlikely to work!
[screenshot]

Requires:

  1. Perl, which kicks ass
  2. convert from ImageMagick
  3. xwininfo, xwd [standard unix utilities]
  4. mozilla (or else modify find_window() for your browser)

Kludges:

License:

This software is essentially free, but please read my payment spiel
Please read the full license

Download:

It's a single perl script.

I also had it working with an older version of opera, but that's not up to date: html2jpg.opera

Documentation?

See the usage for command-line options.

html2jpg supports all the image types that convert supports.
This also means you can specify the type for stdout with a file like: -o gif:-

If the script is renamed (or linked to) as "html2<type>" - then the default image type will be <type>.
(Example: html2png, html2gif, html2jpg, html2ps, ...)

The script does the following:

  1. Loads your url in a browser (with -remote, and all the bugs that has..)
  2. Sleeps for a few seconds (because we don't know when the page is loaded!)
  3. Tries to find the browser window in the Xwindow tree
  4. Tries to find the proper subwindow (so we can ignore menus, window frames, scroll bars..)
  5. Takes a window dump and converts it to the appropriate image type.
This relies on a bunch of unix utilities working just the way they do on my system. Caveat Emptor. :)

Install

It's just a perl script. No install required.

Revision History:

See the CHANGELOG

Freshmeat?

You bet.