From c78f13e04250832cf5ac8a7447817a6c276415b9 Mon Sep 17 00:00:00 2001 From: Devil Date: Thu, 8 Apr 2021 16:36:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E9=87=8D?= =?UTF-8?q?=E7=BB=98=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/base/Uploader.php | 72 ++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/extend/base/Uploader.php b/extend/base/Uploader.php index 05b47c984..f43ce204e 100755 --- a/extend/base/Uploader.php +++ b/extend/base/Uploader.php @@ -230,42 +230,50 @@ class Uploader // 存储图片、使用GD存储图片、防止图片包含木马 // 如未安装相应的gd库则直接存储文件 + // 未开启重新绘制 $is_move = false; - switch($this->fileType) + + // 是否开启图片重新绘制 + if(MyC('is_upload_images_redraw', 0) == 1) { - case '.png': - if(function_exists('imagecreatefrompng')) - { - $image = imagecreatefrompng($file["tmp_name"]); //PNG - imagesavealpha($image, true); //这里很重要 意思是不要丢了$sourePic图像的透明色; - $width = imagesx($image); //图宽度 - $heigh = imagesy($image); //图高度 - $thumb = imagecreatetruecolor($width, $heigh); - imagealphablending($thumb, false); //这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色; - imagesavealpha($thumb, true); //这里很重要,意思是不要丢了$thumb图像的透明色; - if(imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $heigh, $width, $heigh)) + switch($this->fileType) + { + case '.png': + if(function_exists('imagecreatefrompng')) { - imagepng($thumb, $this->filePath); + $image = imagecreatefrompng($file["tmp_name"]); //PNG + imagesavealpha($image, true); //这里很重要 意思是不要丢了$sourePic图像的透明色; + $width = imagesx($image); //图宽度 + $heigh = imagesy($image); //图高度 + $thumb = imagecreatetruecolor($width, $heigh); + imagealphablending($thumb, false); //这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色; + imagesavealpha($thumb, true); //这里很重要,意思是不要丢了$thumb图像的透明色; + if(imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $heigh, $width, $heigh)) + { + imagepng($thumb, $this->filePath); + } + } else { + $is_move = true; } - } else { - $is_move = true; - } - break; - case '.gif': - if(function_exists('imagecreatefromgif')) - { - @imagegif(@imagecreatefromgif($file["tmp_name"]), $this->filePath); - } else { - $is_move = true; - } - break; - default: - if(function_exists('imagecreatefromjpeg')) - { - @imagejpeg(@imagecreatefromjpeg($file["tmp_name"]), $this->filePath, 100); - } else { - $is_move = true; - } + break; + case '.gif': + if(function_exists('imagecreatefromgif')) + { + @imagegif(@imagecreatefromgif($file["tmp_name"]), $this->filePath); + } else { + $is_move = true; + } + break; + default: + if(function_exists('imagecreatefromjpeg')) + { + @imagejpeg(@imagecreatefromjpeg($file["tmp_name"]), $this->filePath, 100); + } else { + $is_move = true; + } + } + } else { + $is_move = true; } // 是否需要直接存储文件