Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Fatal error: Uncaught Error: Call to undefined function imagecreatefrompng() in C:\XAMMP\htdocs\project\admin\functions.inc.php:244 Stack trace: #0 C:\XAMMP\htdocs\project\admin\manage_banner.php(57): imageCompress('C:\\XAMMP\\tmp\\ph...', 'C:/XAMMP/htdocs...') #1 {main} thrown in C:\XAMMP\htdocs\project\admin\functions.inc.php on line 244

What I have tried:

showing to images on localhost of my project but they are not showing to images please read the error and give me solutions Thank you! :)
Posted
Comments
Afzaal Ahmad Zeeshan 28-May-22 17:45pm    
There is an error, it says that the function that you are calling is undefined (not found). Check if you have deployed the entire application or just a single file.
Computer Science May2022 28-May-22 22:27pm    
Fatal error: Uncaught Error: Call to undefined function imagecreatefrompng() in C:\XAMMP\htdocs\project\admin\functions.inc.php:242 Stack trace: #0 C:\XAMMP\htdocs\project\admin\manage_banner.php(57): imageCompress('C:\\XAMMP\\tmp\\ph...', 'C:/XAMMP/htdocs...') #1 {main} thrown in C:\XAMMP\htdocs\project\admin\functions.inc.php on line 242
Computer Science May2022 28-May-22 22:30pm    
////// This functions ////

function imageCompress($source,$path,$quality=60){
$arr=getimagesize($source);
if($arr['mime']=="image/png"){
$i=imagecreatefrompng($source);
}else{
$i=imagecreatefromjpeg($source);
}
imagejpeg($i,$path,$quality);
}



///// This code of banner //
$msg="";

if($msg==''){
if(isset($_GET['id']) && $_GET['id']!=''){
if($_FILES['image']['name']!=''){
$image=rand(111111111,999999999).'_'.$_FILES['image']['name'];
//move_uploaded_file($_FILES['image']['tmp_name'],BANNER_SERVER_PATH.$image);
imageCompress($_FILES['image']['tmp_name'],BANNER_SERVER_PATH.$image);
mysqli_query($con,"update banner set heading1='$heading1',heading2='$heading2',btn_txt='$btn_txt',btn_link='$btn_link',image='$image',order_no='$order_no' where id='$id'");
}else{
mysqli_query($con,"update banner set heading1='$heading1',heading2='$heading2',btn_txt='$btn_txt',btn_link='$btn_link',order_no='$order_no' where id='$id'");
}
Richard MacCutchan 29-May-22 3:29am    
According to PHP: imagecreatefrompng - Manual[^], that is a valid PHP function. Are you using a very old version of PHP?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900