Hello,
I wrote the errors I got across the codes
// Warning: imagecreatefrompng(): ‘images/logo/1659626118.png’ is not a valid PNG file in
// Warning: imagecopyresampled() expects parameter 2 to be resource, bool given in
how can i fix these errors
function boyutla($resim, $tresim, $max_en, $max_boy){
$arraylar = explode('.',$resim);
$sonuc = $arraylar[(count($arraylar) -1)];
$sonuc = trim($sonuc);
$sonuc = strtolower($sonuc);
switch ($sonuc){
case "jpeg": $islem=imagecreatefromjpeg($resim); break;
case "JPEG": $islem=imagecreatefromjpeg($resim); break;
case "jpg": $islem=imagecreatefromjpeg($resim); break;
case "gif": $islem=imagecreatefromgif($resim); break;
case "png": $islem=imagecreatefrompng($resim); break; // Warning: imagecreatefrompng(): 'images/firma_logo/1659626118.png' is not a valid PNG file in
case "JPG": $islem=imagecreatefromjpeg($resim); break;
case "GIF": $islem=imagecreatefromgif($resim); break;
case "PNG": $islem=imagecreatefrompng($resim); break;
}
$boyut = getimagesize($resim);
$en = $boyut[0];
$boy = $boyut[1];
$x_oran = $max_en / $en;
$y_oran = $max_boy / $boy;
if (($en <= $max_en) and ($boy <= $max_boy)){
$son_en = $en;
$son_boy = $boy;
}
else if (($x_oran * $boy) < $max_boy){
$son_en = $max_en;
$son_boy = ceil($x_oran * $boy);
}
else {
$son_en = ceil($y_oran * $en);
$son_boy = $max_boy;
}
$yeni = ImageCreateTrueColor($son_en,$son_boy);
imagealphablending($yeni, false);
imagesavealpha($yeni, true);
$transparent = imagecolorallocatealpha($yeni, 255, 255, 0, 127);
//imagecolorallocatealpha($yeni, $son_en, $son_boy, $en, $boy);
imagefilledrectangle($yeni, 0, 0, $son_en, $son_boy, $transparent);
imagecopyresampled($yeni,$islem,0,0,0,0,$son_en,$son_boy,$en,$boy); // Warning: imagecopyresampled() expects parameter 2 to be resource, bool given in
switch ($sonuc){
case "jpeg": imagejpeg($yeni,$tresim); break;
case "JPEG": imagejpeg($yeni,$tresim); break;
case "jpg": imagejpeg($yeni,$tresim); break;
case "gif": imagegif($yeni,$tresim); break;
case "png": imagepng($yeni,$tresim); break;
case "JPG": imagejpeg($yeni,$tresim); break;
case "GIF": imagegif($yeni,$tresim); break;
case "PNG": imagepng($yeni,$tresim); break;
}
return $resim;
}