RSS

Weblog Thumbnails

20 Jun

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 640x480x24 -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 http://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 1024x768x24 -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 http://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.

Advertisements
 
3 Comments

Posted by on June 20, 2008 in Linux, php, resources

 

Tags: , , , ,

3 responses to “Weblog Thumbnails

  1. Smith

    February 5, 2009 at 2:03 am

    Hi sandeep,
    Have you tried this tool?
    I am very curious about it………

     
  2. svnlabs

    April 20, 2010 at 4:50 pm

    Hello,

    Find webthumb using LAMP here..

    http://blog.svnlabs.com/tag/webthumb/

    Thanks

     
  3. Abheet

    January 20, 2011 at 6:35 am

    Hi Sandeep,

    Well i tried this script but not able to execute it through php code.

    As the shell script execute successfully in terminal but when i tried to execute it from php code with help of shell_exec,sytem,exec functions it didn’t work as i get output from sh file “html 2 image Done!” But actually this command ./html2image $1 /home/siteroot/public_html/html2image/$2 seems to be not executed 😦

    Help needed …. !!

    Regards,
    Abheet

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: