首页 > 编程知识 正文

img片空白怎么解决,img片显示不出来怎么办

时间:2023-05-04 23:04:23 阅读:258539 作者:1912

我正在上传一个文件图像。我将其压缩到指定的宽度和高度,但当我尝试显示一个PNG时它总是显示一个空白图像,但它会显示jpg或jpeg文件。function compress($extention, $destination, $quality, $tmpsource)

{

$extention = strtolower($extention);

list($width, $height) = getimagesize($destination);

$y = (800 * $height / $width);

$getType = null;

if ($extention == "jpeg") {

$source = imagecreatefromjpeg($destination);

}

if ($extention == "jpg") {

$source = imagecreatefromjpeg($destination);

}

if ($extention == "png") {

$source = imagecreatefrompng($destination);

}

$thumb = imagecreatetruecolor(800, $y);

imagecopyresized($thumb, $source, 0, 0, 0, 0, 800, $y, $width, $height);

if ($extention == "jpeg") {

imagejpeg($thumb, $destination, $quality);

}

if ($extention == "jpg") {

imagejpeg($thumb, $destination, $quality);

}

if ($extention == "png") {

imagepng($thumb, $destination, $quality);

}

return $destination;

}

我把它叫做:if (in_array($imgTypeArr[$i], $allowedTypes))

{

$newImgName = uniqid($newUniqName . "_") . "." . $getExt;

$imgUploadArr[] = $newImgName;

$destination = "../images/products/" . $proFolder . "/" . $newImgName;

move_uploaded_file($imgTmpArr[$i], $destination);

compress($getExt, $destination, 100);

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。