img下面的png图片 vs 读不出来,PNG图像加载功能不工作,显示空白图像的问题

我正在上传一个文件图像。我将其压缩到指定的宽度和高度,但当我尝试显示一个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);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值