因此,我创建的PHP文件和一些有用的线程/咨询的脚本上SO以及与此就出来了:阴影正在变成黑色
$filename = time();
$glassurl = $_GET['GlassImg'];
$frameurl = $_GET['FrameImg'];
$handleurl = "images/helpbutton.png";
$handleurl2 = "images/helpbutton.png";
$glassimg = imagecreatefromjpeg($glassurl);
$frameimg = imagecreatefromgif($frameurl);
$handleimg = imagecreatefrompng($handleurl);
$handleimg2 = imagecreatefrompng($handleurl2);
$frame_x = imagesx($frameimg);
$frame_y = imagesy($frameimg);
imagecopymerge($glassimg, $frameimg, 0, 0, 0, 0, $frame_x, $frame_y, 100);
imagecolortransparent($handleimg, imagecolorat($handleimg, 0, 0));
imagecolortransparent($handleimg2, imagecolorat($handleimg2, 0, 0));
$handle_x = imagesx($handleimg);
$handle_y = imagesy($handleimg);
imagecopymerge($glassimg, $handleimg, 460, 150, 0, 0, $handle_x, $handle_y, 100);
$handle2_x = imagesx($handleimg2);
$handle2_y = imagesy($handleimg2);
imagecopymerge($glassimg, $handleimg2, 5, 5, 0, 0, $handle2_x, $handle2_y, 100);
// Output and free from memory
imagepng($glassimg, "uploads/$filename.png");
imagedestroy($glassimg);
imagedestroy($frameimg);
imagedestroy($handleimg);
imagedestroy($handleimg2);
它非常作品完美,但有轻微问题。 helpbutton.png,它只是一个占位符图像,看到我可以定位图像并合并它们,最终会产生一个黑色阴影,导致图像看起来很糟糕。
这是它应该是什么样子:
这是怎么弄出来,一旦合并:
我已经调查了大量的图像控件,包括混合等,但似乎没有影响它。有谁知道如何控制阴影不应该在PHP中变暗?
这可能是因为您上传这不是一个PNG图像尝试上传PNG图像 –
其形象是不是PNG图像?帮助按钮和最终生成的图像都是。你的意思是gif和jpeg? – Bohdi
是的确实.... –