Below is a bash script to install the module and libs that you need (you'll need Xcode/Xcode Command Line Tools installed):
#!/bin/bash JPEG_LION="http://rudix.googlecode.com/files/libjpeg-8d-0.pkg" JPEG_SNOW="http://rudix-snowleopard.googlecode.com/files/libjpeg-8d-0.pkg" echo "Select MacOS Version:" echo "[1] Lion" echo "[2] Snow Leopard" read selection case $selection in 1) OPTION=$JPEG_LION;; 2) OPTION=$JPEG_SNOW;; *) Echo "No Selection Made" exit 0 ;; esac curl -O $OPTION sudo installer -pkg libjpeg-8d-0.pkg -target / sudo easy_install pip sudo pip install pil sudo pip install pillow
Then you could try something like this in Python:
#!/usr/bin/env python
import os,sys,urllib2,Image,ImageDraw,ImageFont
fname = raw_input("Enter Filename: ")
txt = open(fname).readlines()
asset,text1,text2,blank = txt
savedFilename = os.path.basename(asset).strip()
imgfile = urllib2.urlopen(asset)
savedfile = open(savedFilename,'wb')
savedfile.write(imgfile.read())
savedfile.close()
im = Image.open(savedFilename)
font = ImageFont.truetype('/Library/Fonts/Verdana Bold.ttf',14)
box = im.getbbox()
im2=im.crop((box[0], box[1], box[2], box[3]+50))
draw=ImageDraw.Draw(im2)
draw.text((box[1]+10,box[3]+10), text1.strip(),font=font)
draw.text((box[1]+10,box[3]+30), text2.strip(), font=font)
im2.save('output.jpg','JPEG')
The Python script reads a single text file that has the 3 entries you listed, terminated with a blank line.
HTH,
AIR.



Sign In
Create Account

Find content
Not Telling