0

here is the code code below

class Home extends Public_Controller
{
    /**
     * Constructor method
     *`enter code here`
     * @author PyroCMS Dev Team
     * @access public
     * @return void
     */
    public function __construct()
    {
        parent::__construct();  
    }


public function testimg(){
    header("Content-type: image/png");
    $image = imagecreatetruecolor(200, 200);
    imagepng($image);     
}
}

but when i call this controller like (http://localhost/sitename/home/testimg). i got the error below

The image "http://localhost/sitename/home/testimg" cannot be displayed because it contains errors.

Kindly help me with this issue i am new to pyrocms.

2 Answers2

2

Problem Solved : there was always an extra space when echo something, i don't know why - ob_clean() does the job.

public function testimg(){
    ob_clean();
    header("Content-type: image/png");
    $image = imagecreatetruecolor(200, 200);
    imagepng($image);     
}
0

That's nothing to do with PyroCMS or even CodeIgniter, you've just set up the image wrong. That is a generic PHP error.

Phil Sturgeon
  • 30,637
  • 12
  • 78
  • 117
  • thanks for your suggesion. but i think its not a generic php error because when i place this code in a seprate file it works perfactly. for example. this will output a black image with 200 width and 200 hight. but in pyrocms controller its not working. any quick help will appriciated. Thanks – Muhammad Arif Butt Oct 10 '11 at 12:02