Download ACA WebThumb ActiveX |
For Windows 7/Vista/2003/XP/2000
To convert HTML to image with PHP, the easiest way is to use our HTML converter SDK - ACA WebThumb ActiveX.
With a few function calls in PHP, it helps you convert html page from any URL to image or thumbnails easily and quickly, takes the snapshots of given URLs as JPG, GIF, PNG, BMP, TIFF, WMF and EMF image.
A simple PHP Script for converting HTML to image:
<? // PHP html to image. // This script shows how to convert the google.com homepage to a PNG image file. $WebThumb_Maker = new COM('ACAWebThumb.ThumbMaker') or die("Start ACAWebThumb.ThumbMakerfailed"); $WebThumb_Maker->SetURL("http://www.google.com"); if ( 0 == $WebThumb_Maker->StartSnap() ) { // Tanke snapshot successful, call SetImageFile() to save the image as a PNG file. echo "Take snapshot successful." ; $WebThumb_Maker->SaveImage("google.png"); } ?>
Reference
This PHP sample script shows how to make a web thumbnail image from HTML page in the memory and output to client browser.
PHP script file: online-thumb.php <? //---------------------------------------------------------------------------------------- // Script: // online-thumb.php // // Remark: // This sample script shows how to make a web thumbnail in the memory and // output to client browser. // // Parameters: // url: The URL of HTML page that you want to convert. the default URL is // http://www.google.com // width: The thumbnail image width. The default value is 320. // height: The thumbnail image height. The defaul value is 240. // ratiotype: The width/height ratio type. 0: keep ratio by width; 1: keep ratio by height. // The default is 0. // // Example: // <img src="online-thumb.php"> or // <img src="online-thumb.php?url=http://www.google.com"> or // <img src="online-thumb.php?url=http://www.google.com&width=320&height=240&ratiotype=0"> //---------------------------------------------------------------------------------------- // Create instance ACAWebThumb.ThumbMaker $HTML_Converter = new COM("ACAWebThumb.ThumbMaker") or die ("Create ACAWebThumb.ThumbMaker failed. Please make sure the component has been installed."); // Get the parameters $t_strURL = isset($_GET["url"]) ? $_GET["url"] : "http://www.google.com"; $t_iWidth = isset($_GET["width"]) ? $_GET["width"] : 320; $t_iHeight = isset($_GET["height"]) ? $_GET["height"] : 240; $t_iRatioType = isset($_GET["ratiotype"]) ? $_GET["ratiotype"] : 0; // Set the URL and start the snap job. $HTML_Converter->SetURL($t_strURL); if ( 0 == $HTML_Converter->StartSnap() ) { // snap successful, set the thumbnail size and get image bytes $HTML_Converter->SetThumbSize ($t_iWidth, $t_iHeight, $t_iRatioType); //get image bytes by PNG format $t_arrThumbImageBytes = $HTML_Converter->GetImageBytes ("png"); // output the image bytes to client browser if ( count($t_arrThumbImageBytes) > 0 ) { // set the output header as PNG image, then output the thumbnail image bytes. header("Content-type: image/png"); foreach($t_arrThumbImageBytes as $byte) echo chr($byte); } } ?>
* If you have installed ACA WebThumb ActiveX on your computer, you can find this php script in the folder {install-folder}\sample\php\online-thumb.php.
Download ACA WebThumb ActiveX |
For Windows 7/Vista/2003/XP/2000
Reference