本节内容:
dedecms水印png透明显示。
解决方法,如下:
在 include/inc_photograph.php 找到 ImgWaterMark 函数
复制代码 代码示例:
//读取水印图片
if(!emptyempty($w_img) && file_exists($w_img)){
$ifWaterImage = 1;
$info = '';
$water_info = getimagesize($w_img,$info);
$width = $water_info[0];
$height = $water_info[1];
switch($water_info[2]){
case 1 :
if(!function_exists("imagecreatefromgif")) return;
$water_img = imagecreatefromgif($w_img);
break;
case 2 :
if(!function_exists("imagecreatefromjpeg")) return;
$water_img = imagecreatefromjpeg($w_img);
break;
case 3 :
if(!function_exists("imagecreatefrompng")) return;
$water_img = imagecreatefrompng($w_img);
break;
case 6 :
if(!function_exists("imagecreatefromwbmp")) return;
$srcFile_img = imagecreatefromwbmp($w_img);
break;
default :
return;
}
找到 $water_img = imagecreatefrompng($w_img); 将这行修改为:
复制代码 代码示例:
if(!function_exists("imagecreatefrompng")) return;
//经过修改的加水印代码 080818 neo
$water_im_bak = imagecreatefrompng($w_img);
$water_img = imagecreatetruecolor($width,$height);
imagealphablending($water_img,false);
imageSaveAlpha($water_img,true);
$white = ImageColorAllocate($water_img, 255,255,255);
ImageColorTransparent($water_img,$white);
imagecopyresampled($water_img,$water_im_bak,0,0,0,0,$width,$height,$width,$height);
//$water_img = imagecreatefrompng($w_img);
如此,就解决了png水印不能透明显示的问题,大家可以试下。