See the code below and try it. In this code, I am adding my name Deepanker on a image called welcome.jpeg.
$string = "Deepanker";
$im = ImageCreateFromJpeg("welcome.jpeg");
$color = ImageColorAllocate($im, 255, 0, 0);
$px = (Imagesx($im) - 6.5 * strlen($string))/2;
$px = Imagesy($im)- 20;
ImageString($im, 200, $px, $px, $string, $color);
Try this code and let me know if there is any problem in the code.
You can improve this code to adopt the height and width of the images. For this first grab the image dimensions and then adjust your watermark according to it. See this tutorial for advance watermarking technique.