Saturday, 29 January 2011

QSL Cards

At the shack there are thousands of QSL cards stuffed into boxes. As an experiment I decided to see if there was a quick way of scanning these - so using a webcam to capture a still image, followed by a python script to stitch the 2 adjacent images together (as the front and back will be on 2 separate images) I managed 400 or so in a session.

stuffed up on flickr for now till I get round to finding a better place for em.

oh the script? it's my 1st adventure into the Python Imaging Library -- and its rather nice.


#!/usr/bin/python

# Script to generate a single image of a QSL card from 2 adjacent
# scanned images
#
# Andrew Elwell for F6KAR
# This script may be copied or modified under the terms of the GPL
#
# We assume that the cards are arranged with the following seq:
# [- 1F] [1R 2F] [2R 3F] .... where FR are Front and Rear of cards

from PIL import Image
import os

indir = "/home/aelwell/Downloads/qsl/batch2"
outdir = "out/"

#leftbox = (100,100,900,1200)
leftbox = (0,0,750,1000)
rightbox = (850,0,1600,1000)


#todo = os.listdir(indir)
#todo = list(todo)
#todo.sort()
#for i in todo:

for n in range(1,403):
i = "Image-" + str(n) + ".jpg"
image = Image.open(indir + "/" +i)
print i

merge = Image.new('RGB',(1000,1500),)

try:
merge.paste(front,(0,0,1000,750))
except:
print "should skip on 1st iteration"

rear = image.crop(leftbox)
rear = rear.rotate(90)

merge.paste(rear,(0,750,1000,1500))

front = image.crop(rightbox)
front = front.rotate(270)

merge.save(outdir + i,"JPEG")

No comments:

Plotting Lustre MDS stats

At $dayjob we have several large filesystems - for example our /scratch system has 3.1 PB of space using over 1000 HDDs. Although each vendo...