我用这个在PHP中创建动态图像:
$image = imagecreatetruecolor(708, 500);
然后我添加一些自定义,背景色,水印文本。。。
imagefilledrectangle($image, 0, 0, 708, 500, $whiteColor);
imagettftext($image, $fontsize - 3, 0, 400, 500 - $fontsize + 3, $infoColor, $fontfile, $info);
最后保存文件:
imagepng($image, "test.png");
一切都很好,我得到了白色背景的test.png
,水印,一切。
但是这个PHP文件也接收来自JSON的POST
值,其中一个是base64图像。我知道我可以用这样的东西:
$stringImage = imagecreatefromstring(base64_decode($data->image));
但我不知道如何将发布的图片嵌入到我动态创建的图片中。这可能吗?
注意:是的,base64图像是有效的图像
您尝试过使用imagecopy()吗?
http://php.net/manual/en/function.imagecopy.php