PHP GD Library无法显示图片

时间:2012-03-23 20:20:13

标签: php gd

我的PHP的GD库有问题..我已经制作了这个脚本来显示一些用户的统计数据,它无法正常工作。我不知道为什么,但它只是显示了破碎的图片..我怎么能解决它?

谢谢,抱歉英文不好

                     header("Content-type: image/png");

        $image      = imagecreatetruecolor(320, 180);

            $online_ico = imagecreatefrompng("/files/online.png");


            $avatar = imagecreatefrompng("/files/default.png");


        $white  = imagecolorallocate($image, 255, 240, 240);
        $green  = imagecolorallocate($image, 0, 255, 0);
        $red    = imagecolorallocate($image, 255, 0, 0);
        $blue   = imagecolorallocate($image, 9, 105, 162);

        $user_id = "25";
        imagefill($image, 0, 0, $blue); 

        //labels
        imagestring($image, 5, 20, 20, "ID ", $white);
        imagestring($image, 5, 20, 40, "UN", $white);
        imagestring($image, 5, 20, 60, "stats", $white);
        imagestring($image, 5, 20, 80, "name", $white);
        //data
        imagestring($image, 5, 130, 20, $user_id, $white);
        imagestring($image, 5, 150, 40, $user_id, $white);
        imagestring($image, 5, 130, 60, $user_id, $white);
        imagestring($image, 5, 130, 80, $user_id, $white);

        imagecopy($image, $online_ico, 130, 41, 0, 0, 16, 16);
        imagecopy($image, $avatar, 280, 140, 0, 0, 35, 35);

        imagepng($image);

0 个答案:

没有答案