how to display GD graphic in web page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I don't understand what is going on with a simple example I created to 
understand how GD graphics are presented in a web page.

First I created the following simple script (in a file named graphic.php):

// file: graphic.php
<?php
$image = imagecreatefrompng("my_graphic.png");
imagepng($image);
?>

I load that script with my web browser, the image is displayed as expected.

Now if I treat graphic.php as an image, and reference in another page using 
the <img src=graphic.php> tag as in the following:

// my_page.php
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<img src=graphic.php>
</body>
</html>

The page again displays my_graphic.png.

However if I replace:
<img src=graphic.php>

with

<img src=<?php
$image = imagecreatefrompng("my_graphic.png");
imagepng($image);
?> >

my_graphic.png is no longer displayed and the web page gets filled with 
random characters.

Why is this happening or what am I missing.

Thanks for any insight.

Chris 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux