0

For instance, the following script works fine without html
<html><head></head><body><?php $im = imagecreatetruecolor(100, 100);// sets background to red
$red = imagecolorallocate($im, 255, 0, 0);
imagefill($im, 0, 0, $red);

header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?></html>
How could we include a php gd library into html?

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by gunnarflax
0

Doesn't it have something to do with that when you are using just php then you view an image in a browser? Meaning that you use it as a picture viewer just as you would if you were to right click (windows) on a picture on your desktop and choose "open with... firefox". What I believe you are doing now is trying to make a html-document store image information which it cannot. You must first create the image somewhere on the server through the php script you are using and then afterwards include the image path to that image into an img-element in your html document. Something like this:

<img src="<?php createImageAndReturnImagePath(); ?>" alt="image" />

Then I believe it will show correctly. Remember that this is my guess, I haven't tried your code and actually seen what is happening :)

0

I am interested if it is possible to create that image, with Gd library, into a php document containing also html code. So, document extension must be .php.
If not, the image could be included like <img src="image.php" >, but I'm not interested.

0

If that is the case then I believe you can't. The aforementioned way is that way you will have to go. I was just going to post that I just now remembered you just put the php document's path in the img source :) I don't know why you would want to do it like you do but as you know it can't be done.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.