PHP运行错误

<?php//checkwehavethevariabledata//variablearebutton-textandcolor$button_text=$_REQUE... <?php
//check we have the variable data
//variable are button-text and color

$button_text=$_REQUEST['button_text'];
$color=$_REQUEST['color'];

if((empty($button_text)||empty($color))||(!($color=='red'||$color=='blue'||$color=='green')))
{
echo 'Could not create image - from not filled out correctly.';
exit;
}

//create an image of the right background and check size
$im=imagecreatefrompng($color.'-button.png');
if(!$im)
{
echo 'Could not create image.';
exit;
}
$width_image=imagesx($im);
$height_image=imagesx($im);

//out images need an 18 pixel margin in from the edge of the image
$width_image_wo_margins=$width_image-(2*18);
$height_image_wo_margins=$height_image-(2*18);
//work out if the font size will fit and makeit saller untili it does
//start out with the biggest size that will reasonably fit on ourt butons
$font_size=33;

//you need to tell GD2 where your fonts reside
putenv('GDFOUNTPATH=C:\WINDOWS\Fonts');
$fontname='arial';

do
{
$font_size--;

//find out the size of the text at that font size

$bbox=imagettfbbox($font_size,0,$fontname,$button_text);

$right_text=$bbox[2]; //right co-ordinate
$left_text=$bbox[0]; //left co-ordinate

$width_text=$right_text-$left_text; //how wide is it?
$height_text=abs($bbox[7]-$bbox[1]); //how tall is it?
}while($font_size>8&&($height_text>$height_image_wo_margins||$width_text>$width_image_wo_margins));

if($height_text>$height_image_wo_margins||$width_text>$width_image_wo_margins)
{
//no readable font size will fit on button
echo 'Text given will not fit on button.<br />';
}
else
{
//we have found a font size that will fit,now work out where to put it
$text_x=$width_image/2.0-$width_text/2.0;
$text_y=$height_image/2.0-$height_text/2.0;

if($left_text<0)
$text_x+=abs($left_text); //add factor for left overhang
$above_line_text=abs($bbox[7]); //how far above the baseline?
$text_y+=$above_line_text; //add baseline factor

$text_y-=2; //adjustment factor for shape of our template

$white=imagecolorallocate($im,255,255,255);
imagettftext($im,$font_size,0,$text_x,$text_y,$white,$fontname,$button_text);

header('Content-type:image/png');
imagepng($im);

imagedestroy($im);

}

?>

运行时,显示:Warning: imagecreatefrompng(red-button.png) [function.imagecreatefrompng]: failed to open stream: No such file or directory in C:\AppServ\www\21\make_button.php on line 15
Could not create image.

如何办啊
展开
 我来答
777999666qhw
2009-11-09 · TA获得超过4871个赞
知道大有可为答主
回答量:5615
采纳率:25%
帮助的人:4663万
展开全部
$im=imagecreatefrompng($color.'-button.png');错误
具体的就不知道了,刚刚开始看php
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式