因此,我創建的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
是的確實.... –