<?php
// Print two names on the picture, which accepted by query string parameters.

$n1 = 'first text';//$_GET['n1'];
$n2 = 'second text'; //$_GET['n2'];

Header ("Content-type: image/jpeg");
$image = imageCreateFromJPEG("images/back.jpeg");
$color = ImageColorAllocate($image, 0, 0, 0);

// Calculate horizontal alignment for the names.
//$BoundingBox1 = imagettfbbox(13, 0, 'ITCKRIST.TTF', $n1);
$boyX =10; //ceil((125 - $BoundingBox1[2]) / 2); // lower left X coordinate for text
//$BoundingBox2 = imagettfbbox(13, 0, 'ITCKRIST.TTF', $n2);
$girlX =20;// ceil((107 - $BoundingBox2[2]) / 2); // lower left X coordinate for text

// Write names.
$font = __DIR__ .'/ARIAL.TTF';

 imagettftext($image, 53, 0, $boyX+25, 492, $color, $font, $n1);
 imagettftext($image, 53, 0, $girlX+310, 512, $color, $font, $n2);

imagestring( $image, 10, 1, 25, $n1,  $color );

// Return output.
ImageJPEG($image, NULL, 93);
//ImageDestroy($image);


?>