Archive for June 20th, 2008|Daily archive page
Weblog Thumbnails
Html2image
Html2image can convert html to bmp, convert html to png and convert html to jpg.
Installation process
1. Download html2image tool
wget http://www.guangmingsoft.net/htmlsnapshot/html2image.i386.tar.gz
2. Extract html2image
tar xvzf html2image.i386.tar.gz
cd html2image
export LD_LIBRARY_PATH=./
3. Run Xvfb
Xvfb :1 -screen 0 640×480x24 -nolisten tcp -audit 4 -auth X1.cfg & export DISPLAY=:1
(virtual framebuffer X server xvfb provides an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory.)
4. Convert html 2 image by below command
./html2image www.google.com a.jpg
Shell Script to access this tool from command line
#!/bin/bash
cd; cd /opt/html2image
ls
export LD_LIBRARY_PATH=./
#rm /tmp/.X1-lock
./Xvfb :1 -screen 0 1024×768x24 -nolisten tcp -audit 4 -auth X1.cfg & export DISPLAY=:1
./html2image $1 /home/siteroot/public_html/html2image/$2
echo “html 2 image Done!”
PHP script (html_2_image.php)
<?
exec(“export LD_LIBRARY_PATH=/opt/”); // if html2image folder in /opt folder
// here html_2_image is above shell script
exec(“/opt/html_2_image www.yahoo.com yahoo.png”, $result, $returnValue);
?>
Execute “html_2_image.php” with cron job, the result image will saved to “/home/siteroot /public_html/html2image/” folder.
Comments (1)