hi, i have a image which i want to overlay dynamic text and then save it as a .png or .gif how would i go about, ive had alook round php.net but not sure what to search for, example below

PHP Code:
$img 'test.png';
$text =  'Created by '.$name
PHP:4,5

Thanks