Intergration Of Screen Capture Script Into WordPress

Objective is to integrate khtml2png2 into a WordPress template post loop. Captures need to cached. If script is too burdensome on server I’d like the ability to run via command-line or admin interface feeding it with url batch? The below code was an unsuccessful attempt:

<div class=”khtml2png2″>
<?php
$mykey_values = get_post_custom_values(‘web’);
foreach ( $mykey_values as $key => $value ) {
$output_file = $value.”.png”;

if (!file_exists($output_file)){
$cmd = “khtml2png2 –display :2″.
” –width 1024″.
” –height 768″.
” –time 45″.
” –disable-java”.
” –disable-plugins”.
” –disable-redirect”.
” –disable-popupkiller”.
” –nograb”.
” http://”.$value.
” “.$output_file;

echo $value.” <br/ >”;
echo $cmd.” <br/ >”;

exec(“$cmd”);
while(!file_exists($output_file)) { sleep(1); }

echo ‘<img src=”‘.$value.’.png” name=”‘.$value.'” alt=”‘.$value.'” id=”ThumbUrl”> ‘;
}else{
echo ‘<img src=”‘.$value.’.png” name=”‘.$value.'” alt=”‘.$value.'” id=”ThumbUrl”> ‘;
}
}
?>

</div>

There are many articles written about similar for reference:

http://www.semicomplete.com/blog/geekery/xvfb-firefox.html
http://initsix.co.uk/content/khtmld-and-khtml2png2-ubuntu-804-php-screenshot-server
http://khtml2png.sourceforge.net/
http://w3guru.blogspot.com/2010/04/webpage-screen-capturing-using.html
http://wirespeed.xs4all.nl/mediawiki/index.php/Thumbnail_a_website
http://www.thomasgericke.de/v4/interactive/blog/2009/02/howto-grab-and-thumbnail-websites/

Leave a Reply

Your email address will not be published. Required fields are marked *