From 1098c20f2cb5c3650e14a72b0728a71e85ce4bde Mon Sep 17 00:00:00 2001 From: tianya Date: Sat, 21 May 2022 14:24:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=87=87=E9=9B=86=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E8=83=8C=E6=99=AF=E9=BB=91=E8=89=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/inc/inc_archives_functions.php | 1 + src/system/helpers/image.helper.php | 6 +++++ src/system/image.class.php | 29 ++++++++++++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/admin/inc/inc_archives_functions.php b/src/admin/inc/inc_archives_functions.php index 47760f9d..21dcbef7 100644 --- a/src/admin/inc/inc_archives_functions.php +++ b/src/admin/inc/inc_archives_functions.php @@ -101,6 +101,7 @@ function GetCurContent($body) $htd = new DedeHttpDown(); $basehost = IsSSL()? "https://".$_SERVER["HTTP_HOST"] : "http://".$_SERVER["HTTP_HOST"]; $img_array = array(); + $body = str_replace("data-src=","src=", $body); preg_match_all("/src=[\"|'|\s]([^\"|^\'|^\s]*?)/isU", $body, $img_array); $img_array = array_unique($img_array[1]); $imgUrl = $cfg_uploaddir.'/'.MyDate("ymd", time()); diff --git a/src/system/helpers/image.helper.php b/src/system/helpers/image.helper.php index ee09395a..694a4e81 100755 --- a/src/system/helpers/image.helper.php +++ b/src/system/helpers/image.helper.php @@ -71,6 +71,8 @@ if (!function_exists('ImageResize')) { $ni = imagecreate($ftoW, $ftoH); imagecopyresized($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH); } + $alpha = imagecolorallocatealpha($ni, 0, 0, 0, 127); + imagefill($ni, 0, 0, $alpha); switch ($srcInfo[2]) { case 1: imagegif($ni, $toFile); @@ -246,6 +248,10 @@ if (!function_exists('ImageResizeNew')) { $new_height = $target_width; } $new_img = ImageCreateTrueColor($target_width, $target_height); + $alpha = imagecolorallocatealpha($new_img, 0, 0, 0, 127); + imagefill($new_img, 0, 0, $alpha); + imagealphablending($new_img, true); + imagesavealpha($new_img, true); if ($cfg_ddimg_bgcolor == 0) $bgcolor = ImageColorAllocate($new_img, 0xff, 0xff, 0xff); else $bgcolor = 0; if (!@imagefilledrectangle($new_img, 0, 0, $target_width - 1, $target_height - 1, $bgcolor)) { diff --git a/src/system/image.class.php b/src/system/image.class.php index 85fe5d8a..6e8c109d 100755 --- a/src/system/image.class.php +++ b/src/system/image.class.php @@ -54,7 +54,7 @@ class image $this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : ''; $this->imagefunc = function_exists('imagepng') ? 'imagepng' : ''; break; - }//为空则匹配类型的函数不存在 + } //为空则匹配类型的函数不存在 $this->attach['size'] = empty($this->attach['size']) ? @filesize($targetfile) : $this->attach['size']; if ($this->attachinfo['mime'] == 'image/gif') { $fp = fopen($targetfile, 'rb'); @@ -76,8 +76,19 @@ class image { $this->thumb_gd($thumbwidth, $thumbheight, $preview); if ($this->thumbstatus == 2 && $this->watermarkstatus) { - $this->image($this->targetfile, $this->attach,$this->watermarktext,$this->watermarkstatus,$this->watermarktrans,$this->watermarkminheight - ,$this->watermarkminwidth,$this->watermarktype,$this->watermarktrans,true,$this->attach); + $this->image( + $this->targetfile, + $this->attach, + $this->watermarktext, + $this->watermarkstatus, + $this->watermarktrans, + $this->watermarkminheight, + $this->watermarkminwidth, + $this->watermarktype, + $this->watermarktrans, + true, + $this->attach + ); $this->attach['size'] = filesize($this->targetfile); } } @@ -121,8 +132,12 @@ class image $thumb['width'] = ceil($y_ratio * $imagewidth); $thumb['height'] = $thumbheight; } - $targetfile = !$preview ? ($this->thumbstatus == 1 ? $this->targetfile.'.thumb.jpg' : $this->targetfile) : './watermark_tmp.jpg'; + $targetfile = !$preview ? ($this->thumbstatus == 1 ? $this->targetfile . '.thumb.jpg' : $this->targetfile) : './watermark_tmp.jpg'; $thumb_photo = imagecreatetruecolor($thumb['width'], $thumb['height']); + $alpha = imagecolorallocatealpha($thumb_photo, 0, 0, 0, 127); + imagefill($thumb_photo, 0, 0, $alpha); + imagealphablending($thumb_photo, true); + imagesavealpha($thumb_photo, true); imagecopyresampled($thumb_photo, $attach_photo, 0, 0, 0, 0, $thumb['width'], $thumb['height'], $imagewidth, $imageheight); if ($this->attachinfo['mime'] == 'image/jpeg') { $imagefunc($thumb_photo, $targetfile, 100); @@ -147,7 +162,7 @@ class image $imagefunc = $this->imagefunc; list($imagewidth, $imageheight) = $this->attachinfo; if ($this->watermarktype < 2) { - $watermark_file = $this->watermarktype == 1 ? DEDEDATA.'/mark/mark.png' : DEDEDATA.'/mark/mark.gif'; + $watermark_file = $this->watermarktype == 1 ? DEDEDATA . '/mark/mark.png' : DEDEDATA . '/mark/mark.gif'; $watermarkinfo = @getimagesize($watermark_file); $watermark_logo = $this->watermarktype == 1 ? @imagecreatefrompng($watermark_file) : @imagecreatefromgif($watermark_file); if (!$watermark_logo) { @@ -203,6 +218,10 @@ class image break; } $dst_photo = @imagecreatetruecolor($imagewidth, $imageheight); + $alpha = imagecolorallocatealpha($dst_photo, 0, 0, 0, 127); + imagefill($dst_photo, 0, 0, $alpha); + imagealphablending($dst_photo, true); + imagesavealpha($dst_photo, true); $target_photo = $imagecreatefunc($this->targetfile); imagecopy($dst_photo, $target_photo, 0, 0, 0, 0, $imagewidth, $imageheight); if ($this->watermarktype == 1) {