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
https://forums.phpfreaks.com/topic/58583-solved-gd-library/
Share on other sites

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

 

any ideas?

 

While you're reading the manual from Yesideez' link, have a read of imagepng() too, in particular the optional arguments.

Link to comment
https://forums.phpfreaks.com/topic/58583-solved-gd-library/#findComment-291005
Share on other sites

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.