To position the picture in the center of the block?

Derive the price of the goods
$prefix1='88Qn|Q*wcIa5';
$prefix2='{Rvi#wy?r?#1';
$price=77777;
$encode="$prefix1$price$prefix2";
$encode=urlencode(base64_encode($encode));
echo"<img src="text_to_img.php?text=$encode" height="26px" width="200px">";


text_to_img.php
$prefix1='88Qn|Q*wcIa5';
$prefix2='{Rvi#wy?r?#1';
$get=$_GET['text'];
$get=base64_decode(urldecode($get));
$prefixs=array($prefix1,$prefix2);
$get=str_replace($prefix1,"",$get);
$get=str_replace($prefix2,"",$get);
$get=strrev(implode(' ',str_split(strrev($get), 3)));
$result=$get.' UAH.';
if(isset($result)&&!empty($result)){
$image=imagecreatetruecolor(200,26);
$background=imagecolorallocate($image,255,255,255);
$color=imagecolorallocate($image,57,181,74);
$font_file='arial.ttf';
imagefilledrectangle($image,0,0,299,99,$background);
imagefttext($image,17,0,0,21,$color,$font_file,$result);
header('Content-Type:image/png');
imagepng($image);
imagedestroy($image);
}


In imagefttext specifies the indentation from the left, top margin. It looks as follows.
5a735986e9556874045128.png
Now the question is. Is it possible to do so in order not depending on the specified width of the generated image, the text in the image is always located exactly in the center?
June 8th 19 at 16:49
1 answer
June 8th 19 at 16:51
https://www.w3schools.com/css/css_align.asp

img {
 display: block;
 margin-left: auto;
 margin-right: auto;
 width: 40%;
}
)) lol - vivian_Flatley commented on June 8th 19 at 16:54

Find more questions by tags Layout