$pic_path ) { $kk = $k + 1; if ( in_array($kk, $lineArr) ) { $start_x = $line_x; $start_y = $start_y + $pic_h + $space_y; } $resource = imagecreatefromjpeg($pic_path.$format); // $start_x,$start_y copy图片在背景中的位置 // 0,0 被copy图片的位置 $pic_w,$pic_h copy后的高度和宽度 imagecopyresized($background,$resource,$start_x,$start_y,0,0,$pic_w,$pic_h,imagesx($resource),imagesy($resource)); // 最后两个参数为原始图片宽度和高度,倒数两个参数为copy时的图片宽度和高度 $start_x = $start_x + $pic_w + $space_x; } $fname= date('YmdHis').rand(100,999); $imagePath = './Public/Temp/'.$fname.'.jpg'; // header("Content-type: image/jpg"); // imagejpeg($background);die; // 保存图像为 $imagePath.'$fname'.'.jpg' $res = imagejpeg($background,$imagePath); // imagejpeg($background,'./public/$uid_.$group.jpg'); if (false === $res) { return false; } // 释放内存 imagedestroy($background); return $imagePath; } ?>
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces the PHP implementation of image merging in WeChat - Jiugongge pictures, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.