Output image


How do I show the content of an jpg-image with php?


echo '<img src="photo.jpg">';

If thats not what you want you need to give more information

Hi Materix

Do you mean the Exif information embedded within you’re image? If so try: http://pel.sourceforge.net/

I would like to do something like this:
<img src=“image.php”>

And in image.php I would like to output the content of a jpg-file (if it exists). Is this possible?

I still do not understand what this means:

output the content of a jpg-file

Do you want to display a jpg, create a file, show the EXIF data ???

Usually in PHP circles, the image is kept on the hard drive with a path, and a file name.


… and the reference to it (ie its name, image1.jpg) is kept in a database table, usually.

You use PHP to pull that image address out of the database, and then echo it out onto the html page, as shown in the examples above.


// this could have come from your db table
$image = '/images/image1.jpg';

A load of html

<img src="<?php echo $image?>" />

A load more html

If this is not what you mean, perhaps you can explain a little more clearly what you do mean.

Sorry for my bad description of the problem.

I have found, what I was looking for. Here it is:

header(‘Content-Type: image/jpeg’);

So you have a page with:

<img src="image.php"> 

and image.php contains:

 header('Content-Type: image/jpeg');