Page 1 of 1

How do you create an image in code w/header sent already?

Posted: Wed Jun 15, 2005 9:06 pm
by twrofpwr
Hey guys, how do you create an image in php code with the header already set?

do you create a seperate file like say image.php with only the 2 lines, and then call this image.php from a src tag like this <img src=image.php ?? Does this work? It seems to not be working for me

Also can you get gdlib for use on XP, my laptop is using XP and I have php installed on my laptop.

Thanks guys

//image.php
header("Content-type: image/jpeg");
imagejpeg($_SESSION['current_image']);

Posted: Wed Jun 15, 2005 9:14 pm
by neophyte
This done usually with an image tag like this:

Code: Select all

<img src=&quote;image_maker.php?file=someparms&quote;>
image_maker.php makes the image and you use the header() to make the browser think it is an image.

There are some projects that make it easy to have php/apache/mysql on XP

I like xampp at apachefriends.org/en

Posted: Wed Jun 15, 2005 10:14 pm
by timvw
In image.php you need a call to session_start first to make sure $_SESSION data is available...

It should work. (Witness statement from a winxp+apache2+php5+gd2 extension user)

Posted: Thu Jun 16, 2005 3:25 am
by phpScott
yes you can get the gdlib to work.

open your php.ini file and look for the gdlib and remove the ; from in front of it.

save and restart your server.

do a phpinfo to see that it is installed correctly.

the issue may have is the path to your extensions folder.