Auto-crop black margins dynamically of scanned images?
Solution 1:
I would recommend using a free utility called Scan Tailor, which removes borders, straightens and does other fixes to scanned images. Below is the result I got with minimal input to your sample file. While it is hard to say how it will work for an entire batch, but the preliminary results seem promising.
If you are looking for a true scripting solution to the problem you might try your hand at ImageMagick, a very powerful command line utility to work images. Specifically I would look at the sections on removing border and trimming. However I didn't have much luck getting it to work on your test image. You might want to look in the forums, where others seem to have similar issues.
Solution 2:
XnView has a batch processing mode with an auto crop feature:
As you can see, the colour and the tolerance level can be modified as required, so that may help.
IrfanView has a similar feature, although it's a bit more hidden. Under Options > Properties/Settings > Browsing/Editing
you can set the tolerance value for auto crop borders:
You can batch auto crop via File > Batch conversion
:
If none of these help then you might have to break out the big guns and use something like Photoshop, perhaps with appropriate auto crop plugins.