Execute python PIL script from php
<p>Excuse me, I need to use php to execute python code to put text on one image automatically, so I use Python PIL library. I can not get the final image with text on it. Here is my php code and python code.</p>

<pre><code>&lt;?php
   exec("/usr/bin/python test.py Tom");
?&gt;
</code></pre>

<p>Then here is my python code.</p>

<pre><code>#!/usr/bin/python
import sys
def main(argv1):
    if not "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIl" in sys.path:
        sys.path.append("/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIl")
    import Image,ImageDraw,ImageFont
    ttfont = ImageFont.truetype("Arial.ttf",12)
    im = Image.open("test.jpg")
    draw = ImageDraw.Draw(im)
    draw.text((115,180),argv1, fill=(0,0,0),font=ttfont)
    im.save("test1.jpg")

if __name__=="__main__":
    print main(sys.argv[1])
</code></pre>

<p>I have done these already.
(1) I use chmod 777 to this python file and test.jpg.
(2) I also copy the Arial.ttf file to the same folder with python and php code.
(3) My OS is mac OS.</p>

<p>If I comment the line "ttfont = ImageFont.truetype("Arial.ttf",12)",
I can get the final image test1.jpg. If I do not comment this line, I can not get the final image. I just want to know why. Thanks.</p>