| Author |
Message |
omnifarius
Butt Sniffer


Joined: 24 Jul 2001 Posts: 1281
Location: Hotlanta
|
Posted:
Mon Jun 30, 2003 8:04 am Post subject: php images |
|
I'm trying to figure out more of these GD image library functions.
It seems like there is a way to create an image on the fly and display it in the browser without actually saving it to a file.
I was hoping this was possible but so far I can't get it working. I get a stream of some sort but it displays in random characters. I'm trying this with a png and I've put image/png into the header.
$im = imagecreate($xscale, $yscale)
or die ("Cannot initialize new GD Image Stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 233, 14, 91);
imagestring ($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng ($im);
If anyone knows whether I can do this somehow or not let me know. If I have to write to a file I will but I'd rather just display on the fly if possible. |
_________________ A mistake is simply another way of doing things.
The liver is evil and must be punished!!!
|
|
|
|
|
random
Moderator


Joined: 30 Oct 2000 Posts: 3382
Location: Left Field
|
Posted:
Mon Jun 30, 2003 9:22 am Post subject: |
|
Did you put a header?
Header( "Content-type: image/png");
Creating an image on the fly is possible.
I wish I had more time to look at the code you got but im at work. Maybe after... |
_________________ Democracy substitutes election by the incompetent many for appointment by the corrupt few. -George Bernard Shaw
function video() {
die("radio star");
}
|
|
|
|
|
random
Moderator


Joined: 30 Oct 2000 Posts: 3382
Location: Left Field
|
Posted:
Mon Jun 30, 2003 9:24 am Post subject: |
|
Oops! missed the header part of your message.
Do you have the complete image code? variables defined and such?
also, try single quotes on the text you want to display.
imagestring ($im, 1, 5, 5, 'A Simple Text String', $text_color);
|
_________________ Democracy substitutes election by the incompetent many for appointment by the corrupt few. -George Bernard Shaw
function video() {
die("radio star");
}
|
|
|
|
|
omnifarius
Butt Sniffer


Joined: 24 Jul 2001 Posts: 1281
Location: Hotlanta
|
Posted:
Mon Jun 30, 2003 9:30 am Post subject: |
|
that is all of the code.
$xscale = 1000;
$yscale = 40;
$im = imagecreate($xscale, $yscale)
or die ("Cannot initialize new GD Image Stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 233, 14, 91);
imagestring ($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng ($im);
Its pretty much just a snippet from the php site if you couldn't have guessed. I had working image code from another site that wrote the images to file but unfortunately I can't get to it right now. So I'm basically trying to relearn this from scratch.
Hopefully I'll be able to figure it out just by playing with it a while. |
_________________ A mistake is simply another way of doing things.
The liver is evil and must be punished!!!
|
|
|
|
|
csign
Moderator


Joined: 26 May 2001 Posts: 8155
Location: Borneo
|
Posted:
Mon Jun 30, 2003 10:46 am Post subject: |
|
Is this the same as the ImageMagic stuff? |
|
|
|
|
|
|
omnifarius
Butt Sniffer


Joined: 24 Jul 2001 Posts: 1281
Location: Hotlanta
|
Posted:
Thu Jul 03, 2003 12:07 pm Post subject: |
|
Ok well I can't figure this stupid thing out. The best I can get is displaying raw image data. Or at least what I think that is. But I can't figure out how to use imagepng($im) at all. I guess I'm going to resort to using a file. |
_________________ A mistake is simply another way of doing things.
The liver is evil and must be punished!!!
|
|
|
|
|
random
Moderator


Joined: 30 Oct 2000 Posts: 3382
Location: Left Field
|
Posted:
Thu Jul 03, 2003 6:05 pm Post subject: |
|
|
|
|
|
omnifarius
Butt Sniffer


Joined: 24 Jul 2001 Posts: 1281
Location: Hotlanta
|
Posted:
Thu Jul 03, 2003 7:49 pm Post subject: |
|
excellent. thanks. I'll give those a look over the weekend and see if they help. |
_________________ A mistake is simply another way of doing things.
The liver is evil and must be punished!!!
|
|
|
|
|
|
|