Jump to content

[SOLVED] GD library


B34ST

Recommended Posts

Hi the following script gets some data(text) ad makes an image with the text:

 

<?php
header ("Content-type: image/png");
$img_handle = ImageCreate (600, 100) or die ("Cannot Create image");
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
$txt_color = ImageColorAllocate ($img_handle, 0, 100, 255);
$vpos = 10;
$hpos = 5;
$i = 1;
foreach ($score as $skill => $stats)
{
if ($skill)
{
	if ($stats[2] == '')
	{ $stats[2] = '0'; }

	ImageString ($img_handle, 20, $hpos, $vpos,  "$skill $stats[2]", $txt_color);

	$vpos = $vpos + 15;
	if ($i == 5)
	{
		$vpos = 10;
		$hpos = $hpos + 150;
		$i = 0;
	}
	$i++;
}
}
ImagePng ($img_handle);    
?>

 

The image has a black background which I would like to replace with a backgroud image(.gif) already created but so not know how this can be done.

 

Also I would like to add icons(.gif images) to the left of each piece of text ($skill) but do not know if this is possible.

 

Thanks in advance for any help

Link to comment
Share on other sites

I have found out that I can use:

 

$img_handle = ImageCreateFromPNG ("sig.png") or die ("Cannot Create image");

 

to solve the above problem

 

but now I cannot figure out how to save the image rather than just outputting it to the browser.

 

any ideas?

Link to comment
Share on other sites

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.