脚本宝典收集整理的这篇文章主要介绍了php – imagecreatefrompng根本不工作,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$src = @R_512_48@jPEg($tmpName);
和
$src = imagecreateFromgif($tmpName);
但如果图像是png
$src = imagecreatefrompng($tmpName);
在Png情况下,src变量为空,但在jpg和gif中,它显示了它的资源ID.
有人会告诉我我需要做什么吗?
$finfo = finfo_open(FILeiNFO_MIME_TYPE); $mime = finfo_file($finfo,$_FILES['photo']['tmp_name']); unset($_FILES["photo"]["type"]); $_FILES["photo"]["type"] = $mime; if ((($_FILES["photo"]["type"] == "image/gif") || ($_FILES["photo"]["type"] == "image/jpeg") || ($_FILES["photo"]["type"] == "image/jpg") || ($_FILES["photo"]["type"] == "image/pjpeg") || ($_FILES["photo"]["type"] == "image/x-png") || ($_FILES["photo"]["type"] == "image/png")) && in_array($extension,$AllowedExts)) { if ($_FILES["photo"]["error"] > 0) { echo "Error uploading file <a href='step-1.PHP'> Try again. </a>"; $image_check = 0; exIT; } else { $image_check = 1; $fileName = $_FILES['photo']['name']; $tmpName = $_FILES['photo']['tmp_name']; $fileSize = $_FILES['photo']['size']; $fileType = $_FILES['photo']['type']; list($width1,$height1,$typeb,$attr) = getimagesize($tmpName); //$filePath = $uploadDir . $fileName; $size = filesize($_FILES['photo']['tmp_name']); $ext = $_FILES["photo"]["type"]; if ($ext == 'image/jpeg' || $ext == 'image/jpg') { $src = imagecreatefromjpeg($tmpName); } else if ($ext == 'image/gif') { $src = imagecreatefromgif($tmpName); } else if(($ext=='image/png')||($ext=='image/x-png')) { $src = imagecreatefrompng($tmpName); } $newwidth1 = 624; $newheight1 = ($height1 * $newwidth1) / ($width1); $tmp = imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,$newwidth1,$newheight1,$width1,$height1); $filename = "resources/images/" . $append . $_FILES['photo']['name']; if ($ext == 'image/jpeg' || $ext == 'image/jpg') { imagejpeg($tmp,$filename,90); } else if ($ext == 'image/gif') { imagegif($tmp,90); } else if(($ext=='image/png')||($ext=='image/x-png')) { imagepng($tmp,90); }
以上是脚本宝典为你收集整理的php – imagecreatefrompng根本不工作全部内容,希望文章能够帮你解决php – imagecreatefrompng根本不工作所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。