You can use imagecreatefromgif("path/file.gif") to retrieve and return it as an image. If it's an animated gif, then I believe only the first frame will be returned. If it's a custom font you're using or a font not in PHP or the browser, you'll need to load it using imagepsloadfont. To write text, you can either use imagestring, imagepstext or imagegetftext to write text to your image. The difference between these 3 seems to be that imagestring will create a horizontal String but cannot be slanted and you have to position it to be over your image. The latter 2 allow for slant, tightness and other parameters, as well as setting in over the image.
Writing the number of players can be achieved by storing $val into a $GET, $POST or $_SESSION and using it in one of the image-String functions.
Here's a list of all the built-in PHP image functions.