views:

367

answers:

3

i want to know how to convert html file to image

thanks and advance

A: 

You can checkout the source code for the popular BrowserShots service,

http://browsershots.org/

Steve-o
A: 

If you're running Windows, and have the GD library installed, you can use imagegrabwindow. I've never used it myself, but as always, the PHP site has lots of documentation and examples.

John McCollum
A: 

Problem is that you need to implement all the functionality of a browser and an HTTP stack (and this still does not deal with the case where the content is modified using javascript).

As John McCollum says, if you've got the website open in a browser on your PC, then you can use imagegrabwindow or snapsIE (MSIE only)

If you want to to be able to get a snapshot using code only, then you might want to look at one of the off the shelf solutions - AFAIK there are several programs (at least 2 of which are called html2pdf) which will generate a PDF of static html - and its relatively easy using standard tools to trim this to window size and convert to an image file.

e.g. http://search.cpan.org/~AUTRIJUS/PDF-FromHTML-0.08/script/html2pdf.pl

symcbean