I have a bunch of scanned images, these are scanned from a book, and they are scanned left page and right page (i.e. not open book) So this means the left pages have a black border on top left and bottom and the right pages have border on top right and left.
the border is approx 1 inch at 300 dpi and i need to deskew and crop the border off. My code is below. It works but is there a way to combine the initial read with the crop as I am reading the image twice here and It is quite slow - I'm getting approx 1100 images an hour on a Z220 xeon e3125 workstation
Code: Select all
FOR /F %%A IN ('DIR %sourcedir%\*.jpg /B /S /A-D /ON') DO (
FOR /F %%B IN ('convert %%A -scale 5%% -threshold 128 -scale 2000%% -threshold 128 -bordercolor black -border 1x1 -fuzz 20%% -trim -format "%%wx%%h%%X%%Y" info:') DO (
convert %%A -deskew 60%% -crop %%B "A:%%~pnxA"
)
Any ideas ?
I'm just about to split this into creating a listing of crop commands, and then running these commands on another PC but can I speed up the inherent process?
Thanks!