时间:2021-07-01 10:21:17 帮助过:9人阅读
//打开文件$imgA = "phpcn_logo.gif";$imgB = "phpchina.gif";$sourceImg = imagecreatefromgif($imgA);$targetImg = imagecreatefromgif($imgB);//获取文件大小$sourceSize = getimagesize($imgA);$targetSize = getimagesize($imgB);//合并图片imagecopyresized($targetImg, $sourceImg, 0, 0, 0, 0, $targetSize[0], $targetSize[1], $sourceSize[0], $sourceSize[1]);//保存结果$r = imagegif($targetImg, "c.gif");if($r){ echo "成功";}else{ echo "失败";}
//打开文件$imgA = "phpcn_logo.gif";$imgB = "phpchina.gif";$sourceImg = imagecreatefromgif($imgA);$targetImg = imagecreatefromgif($imgB);//获取文件大小$sourceSize = getimagesize($imgA);$targetSize = getimagesize($imgB);//合并图片imagecopyresized($targetImg, $sourceImg, 0, 0, 0, 0, $targetSize[0], $targetSize[1], $sourceSize[0], $sourceSize[1]);//保存结果$r = imagegif($targetImg, "c.gif");if($r){ echo "成功";}else{ echo "失败";}不要GD库,这个我已经实现了,因为速度太慢,想换imagemagick
已经实现,文档看吐了,贴代码啥也不说了
$image = new Imagick('05.png');$imagepng = new Imagick('16.png');$imagepng->setImageFormat("png");$image->compositeImage($imagepng, $imagepng->getImageCompose(), 0, 0);$imagepng->destroy();header("Content-Type: image/png");echo $image;$image->destroy();
直接用imagick。
$cmd = sprintf("composite -gravity %s -geometry %s -dissolve %s '%s' %s %s", 'SouthEast', '+10+10', 100, '16.png', '05.png', '05.png'); exec($cmd);
直接用imagick。
$cmd = sprintf("composite -gravity %s -geometry %s -dissolve %s '%s' %s %s", 'SouthEast', '+10+10', 100, '16.png', '05.png', '05.png'); exec($cmd);