My provious environment is php 5.2, now is php 5.3.
When I moved the website to new environment, it shows the error
The error warning is:
Fatal error: Call to undefined function imagecreatefrompng() in xx/application/libraries/crop2.php on line 537
and the error code is the ninth line in the following code:
protected function IM($file)
{
if(!file_exists($file)) die('File not exists.');
$info = getimagesize($file);
switch($info['mime'])
{
case 'image/gif':
$mim = imagecreatefromgif($file);
break;
case 'image/png':
$mim = imagecreatefrompng($file); // the error line
imagealphablending($mim, false);
imagesavealpha($mim, true);
break;
case 'image/jpeg':
$mim = imagecreatefromjpeg($file);
break;
default:
die('File format errors.');
}
return $mim;
}
How should I change it?
With the help of
phpinfo()check whether you haveGD library for PHP installed. Seems like it’s missing.