Esempio n. 1
0
def main(argv):
  try:
    opts, args = getopt.getopt(argv, "i:d:o:")
  except getopt.GetoptError:
    usage()
    sys.exit(2)
  SKELETON = None
  FORMDATA = None
  OUTFILE = None
  for opt, arg in opts:
    if opt == "-h":
      usage()
      sys.exit()
    elif opt == "-i":
      SKELETON = arg
    elif opt == "-d":
      FORMDATA = arg
    elif opt == "-o":
      OUTFILE = arg
  if not (SKELETON or FORMDATA or OUTFILE):
    usage()
    sys.exit(2)
  # Read the JSON string for the form data from the file
  formdatafile = file(FORMDATA, "r")
  # Load the form data
  formdata = json.load(formdatafile)
  formdatafile.close()
  #
  # Create bubble objects from the form data
  formsets = Bubble.readform(FORMDATA)
  #
  # Load the skeletal form
  form_img = Image.open(SKELETON)
  #
  # Draw the bubbles
  for bs in formsets.sets:
    bs.draw(form_img)
  #
  # Draw the registration markers according to the data
  rmarks = rm.readform(FORMDATA)
  for mark in rmarks:
    mark.draw(form_img)
  #
  # Draw the barcode
  bc.drawbarcode(form_img, FORMDATA)
  #
  # Save the form
  form_img.save(OUTFILE, "TIFF")
Esempio n. 2
0
import formbot.barcode as barcode
import json
import subprocess
import glob
import os

rm.DEBUG = True

FORMDATA = "formdata02.json"
INFILE = "form02.tif"
#QRFILE = "qrcodetest01.png"

form = Image.open(INFILE)
#tmp = Image.open(QRFILE)
#form.paste(tmp, (975,50))
barcode.drawbarcode(form, FORMDATA)
data = barcode.readbarcode(form)

print "Decoded data: %s" % data

# #decode = 'java', '-classpath', ':'.join(glob.glob(os.path.dirname(__file__) + '/lib/*.jar')), 'qrdecode'
# decode = 'java', '-classpath', ':'.join(glob.glob('lib/*.jar')), 'qrdecode'
# decode = subprocess.Popen(decode, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
# 
# form.save(decode.stdin, 'PNG')
# decode.stdin.close()
# decode.wait()
# 
# decoded = decode.stdout.read().strip()
# print decoded