ok the basic idea when creating images this way is to create the image in it's own script, and call the script in an html <IMG...> tag
so you have the image script image.php (use $_GET to pass parameters)
header("Content-type: image/jpeg");
$im = @ImageCreateFromJPEG ("img.jpg");
$color = ImageColorAllocate ($im, 0, 0, 0);
ImageTTFText ($im, 48, 0, 5, 50, $color, "myriadpro-semibold.otf", $text);
ImageJPEG($im);
then you have your table script table.php
echo '<td colspan="2" class="naslov">';
echo '<img src="image.php" alt="x">';
echo '</td>';
it doesn't matter that the html is fetching a .php file as an image - the content-header in the image script tells the browser that it's fetching a jpeg.
hope this helps
adam