0

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?

asked Sep 2, 2011 at 3:27
2
  • 1
    Apparently your new environment doesn't have PHP-GD installed or enabled. Commented Sep 2, 2011 at 3:29
  • 1
    phpinfo() and search for GD Commented Sep 2, 2011 at 3:29

1 Answer 1

1

With the help of phpinfo() check whether you have GD library for PHP installed. Seems like it's missing.

Vishwanath Dalvi
36.9k41 gold badges128 silver badges156 bronze badges
answered Sep 2, 2011 at 4:08
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.