我试图在白色图像中放置一个徽标,并使其成为半透明以用作水印。PHP - 创建一个带有半透明徽标/水印的PNG文件
这里是我的代码...
// 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
...,你可以请参阅图像的右下四角因某种原因变色。
我认为你需要做一些字母。 – putvande
yeah..maybe ..但是logo * *正在被imagecopymerge正确透明化......它只是在$图像上标出了所有“图像之后”的东西......非常奇怪 – menriquez