0

I'm new to learning Python and I've been trying to implement a text to image converter that runs on a web page.

  1. I have succeeded in making the functional code that converts the text into image in Python, using the PIL module (i.e., user enters input text at run time and that gets converted into an image and is stored in the hard drive).

  2. Now I want this code segment to work on a web page (something similar to feedback or comments form in websites).

    a. That asks the user to enter a string in a text field and, on pressing a button, it goes ahead and converts it into an image and reloads the page.

    b. once reloaded it displays the string-converted-image, and also provides the text box again for any new user to do the same.

  3. I started with the Google Web Apps framework, and unfortunately I learnt that Google Web Apps can't support PIL module although it provides an image API, it can't support dynamic image generations based on user input.

  4. So, can anyone guide me as to how I can go ahead and integrate a web page and the Python code that I have ready? So that it works?

  5. Please guide me where I need to look and anything you consider is necessary to know in order to proceed ahead.

jbatista
  • 2,747
  • 8
  • 30
  • 48

2 Answers2

0

Check out webpy, just about the simplest Python web framework. In the web.py module, import your PIL image converter, grab the text from the submitted form (via web.input()), convert the text and render a page with the new image on it. You should be able to get a simple page up in a dozen or so lines.

Hollister
  • 3,758
  • 2
  • 20
  • 22
0

You can use any existing web scripting language to build the actual web page itself. Python (Django?), PHP, ASP.NET, Perl CGI will all work. Then if you're using a python based web framework simply call your python code directly after including the function in your code and serve the resulting generated image. Otherwise you can use a system/exec/passthru call to your code inside of a python script and send the text as input getting the source of the image as output.

To put this all into a webpage you would need the following:

  • A webpage with form and text box
  • A web scripting language page which serves an image after taking text as input through GET or POST. Example: Django Serve Image
  • Once the user submits a form it should load the results of the form data being passed to the script in either a frame or div below the form. This can be done in many different ways with Javascript or Frames.
Community
  • 1
  • 1
YoriKv
  • 851
  • 8
  • 5