PHP imagecreatefrompng会毫无例外地停止代码

I want to use the method imagecreatefrompng in my php code. Before calling this method I have checked that the path is referring to a file and the mime type is image/png these are my watches:

evidence of correct file

But as I try this method $this->image = imagecreatefrompng($bg); the running code stops without any exception:

try {
        $this->image = imagecreatefrompng($bg);
        $this->colour = ImageColorAllocate($this->image, 0, 0, 0); // Black
    } catch (Exception $e) {
        print_r($e);
    } 

How can I check for error?

The problem was all about gd library not being installed on my machine. So I have followed this link to install that and now every thing just goes fine.