Aligning php Generated Image dynamic text in center

后端 未结 4 561
我在风中等你
我在风中等你 2020-12-10 11:25

i want to align the text generated on the image to the center of the image. for the moment, i dont know if it is possible to align it. below is the code.

$i         


        
4条回答
  •  粉色の甜心
    2020-12-10 11:52

    foreach ($user as $key=>$value){    
        $bb = imagettfbbox($value['font-size'],0,$fontname,$value['name']);    
        $WW = abs($bb[2]-$bb[0]);    
        $XX = ($value['XPos']+$WW);    
        $HH = abs($bb[5]-$bb[3]);    
        $HH +=1;
        $HHH += $HH;
        imagettftext($im, $value['font-size'], 0, $value['XPos'],   $value['YPos'], $color[$value['color']], $fontname, $value['name']);  
        $HHH += 1;
        $WIDE = abs($bb[2]-$bb[0]);  
        $endpoint=$value['XPos']+$WIDE;  
        $bb2 = imagettfbbox($value['font-size'],0,$fontname,$value['name']);  
        $WW2 = abs($bb2[2]-$bb2[0]);     
        $x2pos= $endpoint-$WW2;    
        imagettftext($im, $value['font-size'], 0, $x2pos, $value['YPos'], $color[$value['color']], $fontname, $value['name']);
    }
    

提交回复
热议问题