Php 将2个图像合并在一起

Php 将2个图像合并在一起,php,image,merge,gd,Php,Image,Merge,Gd,到目前为止,以下代码成功地将两个图像合并在一起($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.pn

到目前为止,以下代码成功地将两个图像合并在一起($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的顶部,即png放在jpg的顶部,结果大小为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);

我认为不支持将较大的图像复制到较小的图像。将较大图像裁剪为较小图像的大小,然后复制。或者,创建一个较大尺寸的空白图像,然后在其上复制这两个图像