You are here: how to display GD graphic in web page « PHP « IT news, forums, messages
how to display GD graphic in web page

Posted by "Chris" on 10/25/05 03:14

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация