去评论
dz插件网

Discuz修复PNG透明图片生成缩略图时背景变黑的BUG

admin
2022/10/22 07:12:12
解决手机版png透明图片黑底问题

打开 source\class\class_image.php

找到这个函数(所有修改都在这个函数内)
  1. function Thumb_GD() {
下边找到
  1. $copy_photo = imagecreatetruecolor($this->imginfo['width'], $this->imginfo['height']);imagecopy($copy_photo, $attach_photo , 0, 0, 0, 0, $this->imginfo['width'], $this->imginfo['height']);$attach_photo = $copy_photo;
改为
  1. if($this->imginfo['mime'] != 'image/png') {        $copy_photo = imagecreatetruecolor($this->imginfo['width'], $this->imginfo['height']);        imagecopy($copy_photo, $attach_photo , 0, 0, 0, 0, $this->imginfo['width'], $this->imginfo['height']);        $attach_photo = $copy_photo;}
找到(三处)
  1. $thumb_photo = imagecreatetruecolor
下边添加
  1. if($this->imginfo['mime'] == 'image/png') {        imagealphablending($thumb_photo, false);        imagesavealpha($thumb_photo, true);}