1

i am trying to create an ellipse using php gd library; also i want to display something under the ellipse. but the usual echo will not work with this. somebody please help me to find the reason and suggest a solution.

this is my php code

header('Content-type: image/png');
$handle = imagecreate(100, 100);
$background = imagecolorallocate($handle, 255, 255, 255);
$red = imagecolorallocate($handle, 255, 0, 0);
$green = imagecolorallocate($handle, 0, 255, 0);
$blue = imagecolorallocate($handle, 0, 0, 255);
for ($i = 60; $i > 50; $i--)
{
imagefilledarc($handle, 50, $i, 100, 50, 0, 90, $darkred, IMG_ARC_PIE);
imagefilledarc($handle, 50, $i, 100, 50, 90, 360 , $darkblue, IMG_ARC_PIE);
}
imagefilledarc($handle, 50, 50, 100, 50, 0, 90, $red, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, 90, 225 , $blue, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, 225, 360 , $green, IMG_ARC_PIE);
imagepng($handle);

thanks in advance

tismon

4

3 回答 3

1

Of course it won't work. Basic HTML knowledge is necessary before gdlibrary exercises.

Open any HTML page with an image and a text, and see, how it works

于 2010-03-26T06:08:16.117 回答
1

如果要将文本输出到图像,则必须使用执行此操作的图像函数,因此您的第一站应该是 PHP 参考。

http://www.php.net/manual/en/ref.image.php

在那里您会发现以下允许您将文本输出到图像的内容: imagefttextimagepstextimagettftext

查看示例以了解如何使用它们。

于 2010-03-26T07:59:17.000 回答
0

如果您想显示您的省略号和一些附加文本(或 HTML),那么您需要执行以下操作...

<img src="your-script-that-makes-an-elipse.php" alt="Elipse">
<p>This is an elipse.</p>

本质上,您使用 PHP 生成的图像作为 HTML 图像标记的来源。您也可以在此页面中使用正常的“回声”语句。

<img src="your-script-that-makes-an-elipse.php" alt="Elipse">
<p><?php echo $ElipseDescription; ?></p>

如果您在此处查看预览图像的来源,您可以看到这一点 - 较小的图像是由使用 GD 的 PHP 脚本创建的(该脚本还处理预览图像的缓存以加快速度):

http://www.stevefenton.co.uk/Content/Gallery/Gallery/Animals/

于 2010-03-26T08:16:35.147 回答