查看: 39|回覆: 1

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

[複製鏈接]

15

主題

18

回帖

0

積分

热心网友

金币
18
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2010-6-11
發表於 2022-10-22 01:07:15 | 顯示全部樓層 |閲讀模式
解决手机版png透明图片黑底问题

打开 source\class\class_image.php

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

透明, 图片, class, 这个, 函数
回覆

使用道具 舉報

85

主題

267

回帖

0

積分

热心网友

金币
267
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2012-7-2
發表於 2022-10-23 14:55:13 | 顯示全部樓層
史诗级攻略,修复我头疼一年多的顽疾,感谢
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部