<?php
function cimgstr($imgname,$word,$fontsize){
list($width,$height,$imgType) = getimagesize($imgname);
$types = array('1' => 'gif', '2' => 'jpeg', '3' => 'png' );
$createImg = 'imagecreatefrom'.$types[$imgType];
$img = $createImg($imgname);
$red = imagecolorallocate($img, 255,0,0);
$x = ($width - imagefontwidth($fontsize)*strlen($word))/2;
$y = ($height - imagefontheight($fontsize))/2;
imagestring($img, $fontsize, $x, $y, $word, $red);
$save = 'image'.$types[$imgType];
$save($img, 'new_' . $imgname);
imagedestroy($img);
}
cimgstr('logo.gif','qdgithub.com',5);
cimgstr('logo.png','qdgithub.com',5);
cimgstr('me.jpg','qdgithub.com',5);
?>