Jump to content

[SOLVED] gd library - draw image + print stuff before or after


jonniejoejonson

Recommended Posts

The following code uses the gd library to draw a blue sqaure...

 

$width = 50;

$height = 50; 

$image = ImageCreate($width, $height); 

$blue = ImageColorAllocate($image, 56, 102, 211);

ImageFill($image, 0, 0, $blue);

ImageJpeg($image);

 

This works fine until you try and print anything before or after the image...

for example if you

add the print 'hello world' before the ImageJpeg function it breaks...

 

I want to know how you can create agd image and output it with other things like text!

regadrs J

 

for example if

Every image on a web page requires an <img tag - http://w3schools.com/html/html_images.asp

 

The URL that you put into the src="..." attribute must be to a .php script that outputs the correct content-type header followed by the image data (your GD code you posted.)

I want to be able to output both text and an image that i create using the gd library.

 

eg:

$image = ImageCreate(50,50); 

$blue = ImageColorAllocate($image, 56, 102, 211);

ImageFill($image, 0, 0, $blue);

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

ImageJpeg($image);

 

How can i add some text to output before the image is displayed...

regards J

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.