Page 1 of 1

[SOLVED]Question about "ImagePng"

Posted: Sat Jul 18, 2009 9:29 am
by dreamline
Hi All,
I've got a little question about ImagePng. I've read a lot of threads and I've been storing a Png image in a variable with ob_start();. It's a bit hard to explain what I want to do, but I'll give it a try. Because I am using this GD function dynamically I want to print out the contents of the variable to screen inside a <DIV> tag, however it needs to represent itself as an image. How would I print the contents of my variable (which holds the full GD PNG image) into a html page without first saving it to a file? Can I use header types inside my DIVS?

Thanks for any help... :)

Re: Question about "ImagePng"

Posted: Sat Jul 18, 2009 12:06 pm
by jackpf
You have to link to a seperate file.

You could do it in one file like this though:

Code: Select all

 
if(!isset($_GET['blah']))
echo '<img src="'.htmlentities($_SERVER['PHP_SELF']).'?blah=1" />';
else
{
//do all your image stuff
}
 

Re: Question about "ImagePng"

Posted: Sat Jul 18, 2009 9:49 pm
by dreamline
Hi,
Thanks jackpf, it was not the answer I was hoping for because I don't want to write to file and want to output directly in my html page. I guess I will need to create all my text images by hand instead of creating them through imagePNG and then printing it in a html tag.

Thanks for your answer. :)

Re: Question about "ImagePng"

Posted: Sun Jul 19, 2009 6:50 am
by jackpf
I think you misunderstood...you don't have to write anything to a file.

Obviously to link to an image, you have to use an <img> tag. But you need a file to display the image as well.

By doing as I suggested, one file can act as both the picture, and the script that displays it.

Is that not what you wanted?

Re: Question about "ImagePng"

Posted: Sun Jul 19, 2009 8:10 pm
by dreamline
Yes, that's exactly what I want. I guess I did misonderstood. So I'll give it a go to see if I can manage to print to a <img> tag.. :)

Thanks and sorry I misunderstood.

Re: Question about "ImagePng"

Posted: Mon Jul 20, 2009 3:37 am
by jackpf
Lol no problem. Good luck.