我的网站上基本上构建了一个字符编辑器,它会拍摄各种图像并将它们放在一起以形成一个头像。 这是HTML代码:
<div id="AvatarImgFrame">
<img src="http://example.com/public/images/char_elements/base_dark.png"/>
<img src="http://example.com/public/images/char_elements/eyes/blue.png"/>
<img src="http://example.com/public/images/char_elements/eyes/blinking.gif"/>
<img src="http://example.com/public/images/char_elements/hair/brown.png"/>
<img src="http://example.com/public/images/char_elements/mouth/happy.png"/>
<img src="http://example.com/public/images/char_elements/pants/patrick.png"/>
<img src="http://example.com/public/images/char_elements/shoes/black.png"/>
<img src="http://example.com/public/images/char_elements/torso/shirt.png"/>
</div>
我怎么能用PHP-GD将这个div基本编译成一个.gif / png?
答案 0 :(得分:1)
以下是有关如何合并两张图片的示例:您可以使用imagecopy
(http://php.net/manual/en/function.imagecopy.php)
$base = imagecreatefrompng('base.png');
$eyes = imagecreatefromgif('eyes.gif');
imagecopy($base, $eyes, $base_x, $base_y, $eyes_x, $eyes_y, $width, $height);
header('Content-Type: image/png');
imagepng($base);
imagedestroy($eyes);
imagedestroy($base);