Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ran into this same problem with writing text to an image. The issue at hand is that any imaging libraries used on google app engine must be pure python, which rules out PIL.</p> <h2>PyBMP</h2> <p><a href="http://code.google.com/p/pybmp/" rel="noreferrer">PyBMP</a> is a pure-python library that can do simple text rendering. From there you can use google's imaging library to composite the resulting bitmap onto your other pictures. There's some sample code below. The downside is the library lacks nicer features like anti-aliasing and fine control over fonts so the text that it renders looks kind of crappy. It also may or may not handle unicode well.</p> <pre><code># Create the image text_img = bmp.BitMap(300,35,bmp.Color.WHITE) # bmpfont_Tw_Cen_MT_30 is a generated file using PyBMP's tool text_img.setFont(bmpfont_Tw_Cen_MT_30.font_data) text_img.setPenColor( bmp.Color.BLACK ) text_img.drawText(name, 0, 0) </code></pre> <p>After this you can use google's <code>composite</code> function on <code>text_img.getBitmap()</code> as you would any other image.</p> <h2>External Image Processing</h2> <p>If the text isn't good enough (it wasn't for my project), an alternative solution is to set up an external server on a service like Rackspace purely for image processing. Set up an HTTP handler that does your image processing with PIL, and then returns the resulting image. From there you can either </p> <ul> <li>upload the result straight to your static file hosting server (like s3) or</li> <li>get the generated-text image result with app engine's urlfetch library and do the rest of your compositing in app engine</li> </ul> <p>Not pretty, but it gets the job done.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload