我真的找不到成功的方法.我在谷歌上搜索过这个,它要么在图像周围有黑色阴影,要么所有图像都不重叠.你能帮忙吗?
I really cannot find a way to successfully do it.. I've searched google for this and it either has black shades around the images or all the images don't overlap. Could you please help?
我擅长 PHP;我会给自己 2/5.. 如果有人愿意帮助我,我真的很感激.
I am alright at PHP; I'd give myself a 2/5.. I would really appreciate if someone would be willing to help me out.
我正在寻找一个简单的 api,类似于:
I'm looking for a simple api that goes something like:
$color=$_GET['color'];
$face=$_GET['face'];
$hat=$_GET['hat'];
echo '<img src="avatar.php?color=$color&face=$face&hat=$hat">';
提前感谢您的任何帮助.我也可以通过我对其他语言的了解来理解 php,所以不要害怕和我谈论技术;但不要太技术化.
Thanks for any help in advance. I can understand php from my knowledge of other languages, too, so don't be afraid to talk technical with me; but not too technical.
关于这个答案的评论太多了,所以我把它作为答案发布.
there are so many comments on this answer so I'm posting this as an answer.
让它在我的电脑上工作.
Got it working on my pc.
使用斯文代码:
$images = array( $_GET['color'], $_GET['face'], $_GET['hat'] );
// Allocate new image
$img = imagecreatetruecolor(58, 75);
// Make alpha channels work
imagealphablending($img, true);
imagesavealpha($img, true);
foreach($images as $fn) {
// Load image
$cur = imagecreatefrompng($fn);
imagealphablending($cur, true);
imagesavealpha($cur, true);
// Copy over image
imagecopy($img, $cur, 0, 0, 0, 0, 58, 75);
// Free memory
imagedestroy($cur);
}
header('Content-Type: image/png'); // Comment out this line to see PHP errors
imagepng($img);
?>
我像这样重命名了你的图片,这样更容易:
I renamed your images like this so its easier :
微笑:a.png
耳机:b.png
蓝色:c.png
smile : a.png
headset : b.png
blue : c.png
原来问题在于它的分层.把一个放在另一个后面
重命名图像后,使用此 url -- 它将起作用(在我的 PC 上起作用).
after you rename the images, use this url -- it will work(works on my pc).
YOUR_FILE.php?hat=b.png&color=c.png&face=a.png
YOUR_FILE.php?hat=b.png&color=c.png&face=a.png
这仍然会给你一个黑色的背景.我不确定您在服务器上的文件中是否具有与上述完全相同的代码 - 因为我在您的链接上使用了图像顺序,但它没有帮助.尝试将此完全相同的代码复制粘贴到不同的文件上,然后尝试.处理订单并检查结果.
This will still give you a black background. I am not sure if you have the exact same code as above in your file on the server - because I played around with the image order on your link and it does not help. Try copy-pasting this exact same code on a different file and then trying. Play around with the order and check the results.
这篇关于如何通过 PHP 将 3 个图像合并为 1 个图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!