4

How to convert SVG to PNG or JPG image with Python on Google Application Engine? Any idea? Google Application Engine has PIL support. However, PIL doesn't support SVG.

  • 3
    Welcome to Stack Overflow! :) Please note that SO is for _high quality_ questions and answers; we like to help people who have obviously put some effort into asking their question before we put effort into answering their question. (We like a challenge.) I suggest reading http://tinyurl.com/so-hints for more details on what we like to see in our questions. Thanks! – sarnold Jun 22 '11 at 03:20
  • possible duplicate of [Server-side SVG to PNG (or some other image format) in python](http://stackoverflow.com/questions/2932408/server-side-svg-to-png-or-some-other-image-format-in-python) – Matt Ball Jun 22 '11 at 03:21
  • 2
    It sounds like a duplicate but the GAE twist makes the answers from that QA not applicable. Installing Cairo on your server is a great idea if you control the server, but you can't do that on GAE. – jhocking Jun 22 '11 at 03:35
  • @Matt, not a duplicate. The problem with GAE is that it is not possible to install/run binary libraries. Only pure Python2.5 can be used, and the implementation even has some further restrictions – John La Rooy Jun 22 '11 at 04:06
  • 1
    BTW, App Engine does *not* have PIL support. The dev server requires PIL to emulate the images API, but you can't directly use PIL in either the production or dev environments. – Wooble Jun 22 '11 at 18:40

2 Answers2

2

When working with Google App Engine you will need a pure Python library because you can't install anything that's compiled (eg. Cairo). While there are pure Python libraries for creating SVG files (eg. pySVG) I don't think there are any for rasterizing SVG images.

jhocking
  • 5,527
  • 1
  • 24
  • 38
-1

If you manage to find (or write) a pure Python library to do this, it is likely to be prohibitive to run it on GAE due to the amount of computation required and the request time restrictions.

I would consider hosting the image conversion service elsewhere and have the GAE fetch the PNGs from there

John La Rooy
  • 295,403
  • 53
  • 369
  • 502
  • This isn't an answer to the question, it basically says they're wrong to do it this way, but I see no reason why this isn't a legitimate question. This seems more like a comment than an answer to me. – Shaun Mar 19 '15 at 20:55
  • @Shaun, how is it less of an answer than the jhocking's answer? At least this offers a useful alternative solution. – John La Rooy Mar 19 '15 at 21:38