But here goes. Yes you have a lot of script to write but let me tackle the text to image issue. If I recall IMAGE MAGICK can do that. Link about:
With that done you can proceed to craft more script for the backend to get this done.
I have been trying to create a script for my website where I can input a set of textfields and turn these into an image. This is basically the same script so you can preview i.e. if you wanted to add text onto the back of a football top.