Page 1 of 1

Including a page with GD

Posted: Tue Jul 25, 2006 12:12 pm
by Getran
My friend wanted to know, and I have no idea if you can.
Is there any way to include a .html file into an image using GD? It doesn't work with the normal means, but instead gives me an error with the html in the source.

Code: Select all

<? 

header("Content-type: image/png"); 
$string = require("google.html"); 
$im = imagecreatefrompng("ad.png"); 
$orange = imagecolorallocate($im, 220, 210, 60); 
$px = (imagesx($im) - 7.5 * strlen($string)) / 2; 
imagestring($im, 3, $px, 9, $string, $orange); 
imagepng($im); 
imagedestroy($im); 

?>

Posted: Tue Jul 25, 2006 12:41 pm
by feyd
Depending on the image format, yes it is possible, but not likely in the way your friends wants. Your friend likely wants to send both the HTML and image so the HTML shows up and the image shows in the HTML. Instead, the binary image data would be merged into the same stream of data as the HTML in this case.

Posted: Tue Jul 25, 2006 12:44 pm
by Getran
I think he just wants it so like the actualy page is displayed within the image. So like the 'google.html' page that he has is displayed in the image the same way that it would if included simply on a PHP page.

Posted: Tue Jul 25, 2006 12:47 pm
by feyd
he'd have to create a browser window render of the page. Painful, but possible, and already been done.

Posted: Tue Jul 25, 2006 12:58 pm
by Getran
Okay, thanks feyd.