我尝试了很多stackoverflow的答案但无法获得我想要的解决方案,我的代码无法将两个图像正确合并到一个新图像中。
我不想使用ImageMagic Lib
$height = 527;
$width = 1350;
$back_img = 'http://localhost/testphoto/Mtw2xHqGGd5FkDF2eQ4Z.png';
$front_img = 'http://localhost/testphoto/BHp7zWb8MB18sr8mzY1v________________.png';
$image = imagecreatefromstring(file_get_contents($back_img));
$frame = imagecreatefromstring(file_get_contents($front_img));
$image = imagecreatefrompng($back_img);
$frame = imagecreatefrompng($front_img);
imagecopymerge($frame, $image, 100, 100, 100, 100, 100, $height, $width);
imagepng($image, 'image.png');
答案 0 :(得分:0)
您需要使用imagecopy()函数,而不是imagecopymerge()。
示例:
imagecopy($FirstImage, $NewImage,$centerXofNewImageInTheFirstImage,$centerYofNewImageInTheFirstImage,$xStartofNewImage,$yStartofNewImage,$xENDofNewImage,$yENDofNewImage);