Here are a more complete examples of using htmlsnapshot to convert html to image with php on Windows.
Note the following things:
1. You copy/paste the below code into test.php and run on command line
php.exe test.php
2. Yon can see it uses GetErrorCode to handle errors to make your code more robust.
<?php
$url = “http://google.com/“;
$path = “.\”;
$img = “1.jpg”;
$timg = “1s.jpg”;
$limg = “1b.jpg”;
$iimg = “1i.jpg”;$com = new COM(“HTMLSNAP2.HtmlSnap.1″);
$com->SetTimeout(150000);
$com->SetDelayTime(5000);
$com->EnableActiveX(true);
$com->EnableJava(true);
$com->EnableScript(true);
$com->EnableActiveX(true);
$com->SetJPEGQuality(100);
$com->SetSmoothingMode(2);
$com->SetInterpolationMode(6);
$com->SnapUrl($url, $path.$img );$err = $com->GetErrorCode();
if ($err == 1)
{$com->SetClipRect(0, 0, 1024, 768);
$com->SaveImage($path.$iimg);$com->GetThumbnailImage($path.$img, $path.$timg, 160, 120, 0);
$com->GetThumbnailImage($path.$img, $path.$limg, 320, 240, 0);
$com->Clear();print “Snapshot of “.$url.”. Click to enlarge<br>”;
print “<a href=”.$iimg.” mce_href=”.$iimg.”><img src=”.$timg.” mce_src=”.$timg.”><img src=”.$limg.” mce_src=”.$limg.”></a><br/>”;
}
else
{
print “error happens”;
}
?>