This code is append Text on Image while uploading a new image.
<form name="form1" method='post' enctype="multipart/form-data">
<table align='center'>
<tr><td>Image</td><td><input type="file" name="file" id="file"/></td></tr>
<tr><td colspan='2' align='center'><input type='submit' value='submit' name='submit'></td></tr>
</table>
</form>
$newname="alter.jpg";
$copied = copy($_FILES['file']['tmp_name'], $newname);
$im = imagecreatefromjpeg($newname);
$textcolor = imagecolorallocate($im, 3, 3, 255);
// Write the string at the top left
imagestring($im, 12, 0, 0, 'Hello world!', $textcolor);
imagejpeg($im,$newname)