Including a page with GD

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Including a page with GD

Post 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); 

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

he'd have to create a browser window render of the page. Painful, but possible, and already been done.
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

Okay, thanks feyd.
Post Reply