//把图片向下连接,变成长图
//images 为字符转已,连接
//filename 保存路径
function join_image($images,$filename){
$images=explode(',',$images);
$height=0;
$witch=0;
$arr=[];
$arr_witch=[];
$arr_height=[];
foreach($images as $v){
// dump(getimagesize($v));
$height+=getimagesize($v)[1];
if(getimagesize($v)[0]>$witch){
$witch=getimagesize($v)[0];
}
if(getimagesize($v)['mime']=='image/jpeg'){
array_push($arr,imagecreatefromjpeg($v));
array_push($arr_witch,getimagesize($v)[0]);
array_push($arr_height,getimagesize($v)[1]);
}
if(getimagesize($v)['mime']=='image/png'){
array_push($arr,imagecreatefrompng($v));
array_push($arr_witch,getimagesize($v)[0]);
array_push($arr_height,getimagesize($v)[1]);
}
}
$thumb=imagecreatetruecolor($witch,$height);
$dst_y=0;
foreach($arr as $key=>$v){
imagecopyresized($thumb, $v,0, $dst_y, 0, 0, $arr_witch[$key], $arr_height[$key], $arr_witch[$key], $arr_height[$key]);
$dst_y+=$arr_height[$key];
}
$filename=md5(uniqid()).'jpg';
imagejpeg($thumb,$filename);
imagedestroy($thumb);
}
php 把图片向下连接,变成长图
最新推荐文章于 2023-09-11 22:40:15 发布