Semi-automatic photo scanning

For anyone who has a lot of photos to scan, the idea of scanning multiple photos and looking through each file to cut and paste the photos into individual photos can be real turn off if not much time is available. I know I certainly don't want to have to crop each photo out. Shouldn't there be some way for the computer to automatically pick out each individual photo? Luckily, there is.

Below I present a script, that coupled with some intelligent scanning methods, automates the process of splitting the scan file into individual files of single photos. The ImageMagick package is a set of command line tools that can do all kinds of things with images, including extracting regions of photos. If I know the size of page, the size of the photos, their position on the page, and the scan density (dpi), then I can use a script to extract each photo from the aggregate scan.

I made and printed a template that contains boxes slightly bigger than the photos at known positions on the page. In this case I am using 4x6 photos and US Letter paper. Two photos can fit on one page. The left edge of the boxes is at 1.25" from the left edge of the paper. The top edges of the photos are at 1.0" and 6.0" from the top edge of the paper. The boxes are 4.05" by 6.05" so the photos can fit inside.

Scanning at 600 dpi gives me two areas that measure 3630x2430 pixels and are located 750 pixels from the left and 600 or 3600 pixels from the top. This information can easily be incorporated into a script that extracts just the photos from the file specified on the command line. In my case, the scanner produces PDF files. The script is below (note that it only has three lines in the actual file. It may be displayed differently):

#!/bin/bash
convert -density 600x600 -extract 3630x2430+750+600 ${1} ${1}-top.png
convert -density 600x600 -extract 3630x2430+750+3600 ${1} ${1}-bottom.png

It is run like this:
extractphotos ScannedFile.pdf

And produces ScannedFile.pdf-top.png and ScannedFile.pdf-bottom.png

Comments

Popular posts from this blog

iChat IRC transport with OpenFire and Kraken

Save kerberos password in keychain for use with kinit on MacOS (was OS X) for use with network drives

Recording the iPhone screen and Mac screen at the same time in one video