LITTLEBLACKDOG.COM Forum Index LITTLEBLACKDOG.COM

 
LWD LWD   FAQ FAQ   Memberlist Memberlist   Usergroups Usergroups   Active Topics Active Topics   Register Register  
  Profile Profile   Log in to check your private messages Log in to check your private messages   Log in Log in  
  Who is Online Who is Online   Image Gallery Image Gallery   Chat Chat   Search Search  
  LWDGear       LBDGear  

View next topic
View previous topic
Post new topic     Reply to topic   LITTLEBLACKDOG.COM Forum Index » Code Warriors
Author Message
omnifarius
Butt Sniffer
Butt Sniffer


Joined: 24 Jul 2001
Posts: 1281
Location: Hotlanta

Post Posted: Mon Jun 30, 2003 8:04 am   Post subject: php images Reply with quote Back to top  

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.

Code: Select all
$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!!!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger ICQ Number
random
Moderator
Moderator


Joined: 30 Oct 2000
Posts: 3382
Location: Left Field

Post Posted: Mon Jun 30, 2003 9:22 am   Post subject: Reply with quote Back to top  

Did you put a header?
Code: Select all
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
Code: Select all
function video() {
die("radio star");
}
View user's profile Send private message Send e-mail AIM Address ICQ Number
random
Moderator
Moderator


Joined: 30 Oct 2000
Posts: 3382
Location: Left Field

Post Posted: Mon Jun 30, 2003 9:24 am   Post subject: Reply with quote Back to top  

Oops! missed the header part of your message. Embarassed

Do you have the complete image code? variables defined and such?

also, try single quotes on the text you want to display.

Code: Select all
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
Code: Select all
function video() {
die("radio star");
}
View user's profile Send private message Send e-mail AIM Address ICQ Number
omnifarius
Butt Sniffer
Butt Sniffer


Joined: 24 Jul 2001
Posts: 1281
Location: Hotlanta

Post Posted: Mon Jun 30, 2003 9:30 am   Post subject: Reply with quote Back to top  

that is all of the code.

Code: Select all

$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!!!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger ICQ Number
csign
Moderator
Moderator


Joined: 26 May 2001
Posts: 8155
Location: Borneo

Post Posted: Mon Jun 30, 2003 10:46 am   Post subject: Reply with quote Back to top  

Is this the same as the ImageMagic stuff?
View user's profile Send private message Send e-mail
omnifarius
Butt Sniffer
Butt Sniffer


Joined: 24 Jul 2001
Posts: 1281
Location: Hotlanta

Post Posted: Thu Jul 03, 2003 12:07 pm   Post subject: Reply with quote Back to top  

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!!!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger ICQ Number
random
Moderator
Moderator


Joined: 30 Oct 2000
Posts: 3382
Location: Left Field

Post Posted: Thu Jul 03, 2003 6:05 pm   Post subject: Reply with quote Back to top  

try this tutorial
http://www.zend.com/zend/tut/dynamic.php

i think this one will give you all you need.
http://www.phpbuilder.com/columns/rasmus19990124.php3

_________________
Democracy substitutes election by the incompetent many for appointment by the corrupt few. -George Bernard Shaw
Code: Select all
function video() {
die("radio star");
}
View user's profile Send private message Send e-mail AIM Address ICQ Number
omnifarius
Butt Sniffer
Butt Sniffer


Joined: 24 Jul 2001
Posts: 1281
Location: Hotlanta

Post Posted: Thu Jul 03, 2003 7:49 pm   Post subject: Reply with quote Back to top  

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!!!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger ICQ Number
Display posts from previous:   
Post new topic     Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours

Help us keep advertisements off this site. Donate today!