Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.