dreamMyDream2014 2013-11-20 20:31
浏览 61

比赛生成器PHP

I found this package and I am trying to run the example and the show the bracket.

But it outputs some weird characters:

�PNG  IHDR�Ht�4PLTE���U��~�IDATx����o�V��GIW&q�*�=ު`B�&��?�?!R*Mv� 

You get the point.

I am thinking that it's because:

// If GD-lib is installed, the below code will draw the bracket of the knock-out      tournament.
if ($GDLIB_INSTALLED) {
$im = $KO->getImage("Tournament name here");
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}

But I dont know how to fix it....

Thanks, Ara

EDIT:

So I changed the code a bit after what gat said.

In my controller, I got: public function getTest(){

    // Depending on whether or not GD-lib is installed this example file will output differently.
    $GDLIB_INSTALLED = (function_exists("gd_info")) ? true : false;


    // Lets create a knock-out tournament between some of our dear physicists.
    $competitors = array(
        'Paul A.M. Dirac', 
        'Hans Christian Oersted', 
        'Murray Gell-Mann', 
        'Marie Curie', 
        'Neils Bohr', 
        'Richard P. Feynman', 
        'Max Planck');

    // Create initial tournament bracket.
    $KO = new TournamentGeneratorGD($competitors);
    $KO->setResByMatch(1, 1, 4, 0);


    if($GDLIB_INSTALLED){
        $im = $KO->getImage("Tournament name here");
        return View::make('test_img')
                    ->with('im', $im);
    }
    else
        return View::make('home');
}

And in my test_img.php page, I got this:

<?php   
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

It doesnt work anyway..

  • 写回答

1条回答 默认 最新

  • doonbfez815298 2013-11-20 20:40
    关注

    header('Content-type: image/png'); should be the first thing you say before outputting anything else.

    Try moving the following code to a different source file (img.php or something).

    header('Content-type: image/png');
    $im = $KO->getImage("Tournament name here");
    imagepng($im);
    imagedestroy($im);
    

    You may then redirect the page to img.php in your if ($GDLIB_INSTALLED) block.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集