Just in case someone is wanting to do what I wanted to do and needs a little
assistance in getting it all working ...
I recently used the Gimp and BatchDivideScannedImages to process 68 directories containing
310 scans into 872 photos.
I did this via the command line running Debian GNU/Linux 5.0 (it should
work the same on any system that is capable of running the Gimp). The final result after
more than 2 days of processing time (on an apple G4) gave me 868 photos. I got the
missed 4 photos by hand clipping three images that had not been completely divided.
I used a python script to 'walk' the directory structure that contained the scanned
images, creating a duplicate structure to store the photos in. For each directory of
scans I executed the following command:
gimp -ibdf '(script_fu_BatchDivideScannedImagesCL "/scanned-images-dir" 0 20 1500 5 3 100 100 "/directory-for-photos" 0 "photo-prefix_" 1)' -b '(gimp-quit 0)'
*** explanation of parameters
image- name of the dir where scanned images are located
inLayer- don't know why, just left this at zero
inThreshold- tried lots of values here (from 10-80), 20 gave me the best results
inSize- I scanned at 600px/in so I set this to 1500 to filter out unwanted selections
inLimit- don't know why, just left this at five
inCorner- the least used corner of the scanner bed (lower right for me).
inX- I used 100 to make sure I was away from the scanner edge effects
inY- I used 100 to make sure I was away from the scanner edge effects
inSaveFiles- not used for batch mode
inDir- name of the dir where the photos should be saved
inSaveType- type of image file, zero is for jpg
inFileName- add this text to the front of the filename
inFileNumber- the filename is indexed by a number (i.e. "00001"), this is the start number to use
*** other considerations and changes I made to DivideScannedImages.scm
I made some changes to the script and saved my own version as DivideScannedImagesCL.scm:
1) I commented out all references to 'display' in the script so that it wouldn't try to open
the gimp ui when processing the images. It was going to run on a headless server anyway
and it won't run at all if you use the "-i" gimp parameter with the gui enabled.
2) I added a 20 pixel radius to the background color selection code. As written the script
picks the background color from a single pixel located at X,Y. I found, that with my
scanner, picking out one pixel for the background color never gave me an accurate color.
A 20 pixel radius may be more than necessary, I had lots of room so it worked good for me.
3) I added a few lines near the start of the script that put a background border (50 pixels) around
the scanned image (using a 20 pixel radius for color selection). My scanner produces a brownish
border around the scan which will interfere with selecting any photos that are near to or pushed
up against the edge of the glass (the easiest way to align them). This border is an 'inside' border
and as such will mask the brown edge, creating a uniform background from edge to edge. It will
also clip a small edge off the photo (most photos are going to be 2500+ pixels wide anyway).
Here's the code, note the last line gives you the location where I inserted this into the script
(very near the top):
; start add inside border
(gimp-selection-shrink img 50)
(set! drawable (car (gimp-image-get-active-drawable img)))
(gimp-context-set-background (car (gimp-image-pick-color img inLayer (- width inX) (- height inY) FALSE TRUE 20)))
(gimp-edit-bucket-fill-full drawable BG-BUCKET-FILL NORMAL-MODE 100 5 TRUE TRUE SELECT-CRITERION-COMPOSITE 100 100)
; end add inside border
;set up saving
4) This represents near flawless accuracy in dividing scanned photos. It saved me many hours of time
I would have had to spend individually processing the scans (using the very awkward gui software that
comes with most scanners). Spend some time testing the threshold and size filters on your most
difficult scans to make sure they are effective. Really look at your scanned image background and
border before you commit to scanning large numbers of photos. You want a uniform background
color - in my opinion as white as you can get it - from edge to edge. You can adjust the scanning
software to produce the best possible background color.
5) Thank you Rob Antonishen for a wonderfully effective Gimp script.