Você está na página 1de 1

$text = "TEST";

$font = $font7;
$size = 60;
$angle = 0;
//$imagem = imagecreatefromjpeg("cars.jpg");
//choose textcolor (white)
$col = $red;
//check width of the text
$bbox = imagettfbbox ($size, $angle, $font, $text);
$bbox["left"] = 0- min($bbox[0],$bbox[2],$bbox[4],$bbox[6]);
$bbox["top"] = 0- min($bbox[1],$bbox[3],$bbox[5],$bbox[7]);
$bbox["width"] = max($bbox[0],$bbox[2],$bbox[4],$bbox[6]) - min($bbox[0],$bbox[2],
$bbox[4],$bbox[6]);
$bbox["height"] = max($bbox[1],$bbox[3],$bbox[5],$bbox[7]) - min($bbox[1],$bbox[3],
$bbox[5],$bbox[7]);
extract ($bbox, EXTR_PREFIX_ALL, 'bb');
$width = imagesx($imagem);
$height = imagesy($imagem);
$pad = 0;
//write text

// top:
imagettftext($imagem, $size, $angle, $width/2-$bb_width/2, $bb_top+$pad, $col,
$font, $text);

// left:
imagettftext($imagem, $size, $angle, $bb_left+$pad, $height/2-$bb_height/2, $col,
$font, $text);

// bottom:
imagettftext($imagem, $size, $angle, $width/2-$bb_width/2, $height-$bb_height-$pad,
$col, $font, $text);

// right:
imagettftext($imagem, $size, $angle, $width-$bb_width-$pad, $height/2-$bb_height/2,
$col, $font, $text);

// center:
imagettftext($imagem, 70, 0, $width/2-$bb_width/2, $bb_top+250, $col, $font,
$text);

imagettftext($imagem, 70, 0, $width/2-$bb_width/2, $bb_top+500, $col, $font,


$text);

imagettftext($imagem, 70, 0, $width/2-$bb_width/2, $bb_top+750, $col, $font,


$text);

Você também pode gostar