到目前为止,以下代码成功地将2个图像合并在一起($ dest为573x311 abd $ src为428x255)。合并后的结果是573x311。这是:
$dest = imagecreatefrompng('images/project-laptop.png');
$src = imagecreatefromjpeg('images/project-laptop-site.jpg');
$merged_image = "images/project-laptop-site_merged.png";
imagealphablending($dest, false);
imagesavealpha($dest, true);
imagecopymerge($dest, $src, 73, 19, 0, 0, 428, 255, 100);
imagepng($dest, $merged_image);
即使这样可行,我真正想要的是颠倒顺序(将$ dest放在$ src之上,即jpg顶部的png,结果大小为573x311)。以下代码无效:
$src = imagecreatefrompng('images/project-laptop.png');
$dest = imagecreatefromjpeg('images/project-laptop-site.jpg');
$merged_image = "images/project-laptop-site_merged.png";
imagealphablending($dest, false);
imagesavealpha($dest, true);
imagecopymerge($dest, $src, 73, 19, 0, 0, 573, 311, 100);
imagepng($dest, $merged_image);
答案 0 :(得分:1)
我不认为支持将较大的图像复制到较小的图像中。将较大的图像裁剪为较小图像的大小,然后复制。或者,创建较大尺寸的空白图像,然后将其复制到其上。