3v4l.org

run code in 300+ PHP versions simultaneously
<?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); } } ?>

preferences:
38.46 ms | 402 KiB | 5 Q