【发布时间】:2013-12-10 17:22:22
【问题描述】:
我正在尝试将徽标放入白色图像中并使其半透明以用作水印。
这是我的代码...
// load the stamp and the photo to apply the watermark to
if (file_exists($logoPath)) {
$im = imagecreatefrompng($logoPath);
$size = getimagesize($logoPath);
$stamp = imagecreatetruecolor(612, 792);
imagefilledrectangle($stamp, 0, 0, 612-1, 792-1, 0xFFFFFF);
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// center width and height
$centerX=$sx/2-$size[0]/2;
$centerY=$sy/2-$size[1]/2;
$res=imagecopymerge($stamp, $im, $centerX,$centerY, 0, 0, $sx, $sy, 15);
$waterPath = $watermark_path.$broker_id."_watermark.png";
// Save the image to file and free memory
imagepng($stamp, $waterPath);
imagedestroy($stamp);
imagedestroy($im);
}
在我看来一切都很好,但是当我运行它时,我得到了这个......
http://i43.tinypic.com/2cyft06.jpg
...如您所见,由于某种原因,图像的右下角四边形被着色了。
【问题讨论】:
-
我认为你需要对 alpha 做一些事情。
-
yeah..maybe..but the logo is is made transparent with the imagecopymerge ...它只是为图像“之后”出现的 $stamp 上的所有内容着色...很奇怪