// select the font
$font = "c:/Windows/Fonts/arial.ttf";
$size = 12;
// load the image
$image = imagecreatefrompng("c:/xampp/htdocs/webshopy.com/button.png");
// get the text width
$text_size = imagettfbbox($size, 0, $font, "hello");
// get the image center
$px = abs($text_size[2] - $text_size[0]);
$py = abs($text_size[5] - $text_size[3]);
$x = (imagesx($image) - $px) / 2;
$y = (imagesy($image) - $py) / 2 + $py;
// set text color
$color_black = imagecolorallocate($image, 0, 0, 0);
// draw text
imagettftext($image, $size, 0, $x, $y, $color_black, $font, "hello");
// output the image
header("Content-type: image/png");
imagepng($image);