Alinhamento de texto pela direita com imagem
Ola,
Tenho um sistema de gerar assinatura, porem o modelo da assinatura mudou, antes o alinhamento das informações era para direita, porem agora é alinhado na esquerda.
O tamanho total da imagem gerada é de 700 e preciso que o final do texto fique alinhado na posição 400, ou seja não importa o tamanho das informações, devera sempre alinha no final na posição 400 da imagem.
Fiz alguns teste, porme não funcionou pois o tamanho do texto varia bastante.
Alguém tem alguma dica, luz para me ajudar?
aguardo.
Obrigado
<?php
// carregar imagem base:
$img = imagecreatefrompng("image-blank.png");
// if there's an error, stop processing the page:
if(!$img)
{
die("");
}
// Cores:
$black = imagecolorallocate($img, 0, 0, 0);
$navy = imagecolorallocate($img, 0, 0, 0);
$blue = imagecolorallocate($img, 0, 0, 0);
$AzulClaro= imagecolorallocate($img, 0, 0, 0);
$AzulEscuro= imagecolorallocate($img, 0, 0, 0);
// Tamanho da Imagem:
$width = imagesx($img);
$height = imagesy($img);
$nome = strtoupper($_POST["nome"]);
$funcao = $_POST["funcao"];
$email = $_POST["email"];
$fone1 = '+55 ('.$_POST["numero1"]["area"].") ".$_POST["numero1"]["phone"];
$fone2 = '+55 ('.$_POST["numero2"]["area"].") ".$_POST["numero2"]["phone"];
$fone3 = ' '.$_POST["numero3"]["phone"];//-----------
$fone4 = ' '.$_POST["numero4"]["phone"];
//---------
$size = 15;
$font = 'calibri.ttf';
$font2 = 'calibri Bold.ttf';
//---------
//$PosiTxt = '400';
//$leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2;
//$ltpNome = ( $width - imagefontwidth(700)*strlen($nome) )-345;
//$ltpNome = ( $width - imagefontwidth(700)*strlen($nome) )-375;
//$ltpFuncao = ( $width - imagefontwidth(700)*strlen($funcao) )-320;
//$ltpFone1 = ( $width - imagefontwidth(700)*strlen($fone1) )-322;
//$ltpFone2 = ( $width - imagefontwidth(700)*strlen($fone2) )-320;
//$ltpFone3 = ( $width - imagefontwidth(700)*strlen($fone3) )-375;
//$ltpEmail = ( $width - imagefontwidth(700)*strlen($email) )-345;
//$ltpteste = ( $width - imagefontwidth(700)*strlen($teste) )-345;
//imagestring($img, $font, $leftTextPos, $height-50, $text, $yellow);
$linha3 = 140;
imagettftext($img, 18, 0, $ltpNome, 50, $AzulEscuro, $font2, $nome);
imagettftext($img, $size, 0, $ltpFuncao, 75, $AzulClaro, $font, $funcao);
imagettftext($img, $size, 0, $ltpEmail, 155, $AzulEscuro, $font, $email) ;
if ($_POST["numero1"]["area"]) {
imagettftext($img, $size, 0, $ltpFone1, 110, $AzulEscuro, $font, $fone1);
$linha3 = 160;
}
if ($_POST["numero2"]["area"]) {
imagettftext($img, $size, 0, $ltpFone2, 135, $AzulEscuro, $font, $fone2);
$linha3 = 160;
}
$img2 = imagecreatetruecolor(490, 140);
imagecopyresampled($img2, $img, 0, 0, 0, 0, 490, 140, 700, 200);
$file = $nome.".png";
header("Content-disposition: inline; filename=$file");
header('Content-Type: image/png');
imagepng($img2);
// tidy up
imagedestroy($img);
?>
Discussão (0)
Carregando comentários...