Is there a tool to autocrop and straighten scanned images?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: sheep, Hacker, Stefan2, white

Post Reply
mikedepetris
Junior Member
Junior Member
Posts: 77
Joined: 2006-11-07, 16:36 UTC
Location: Trieste, Italy
Contact:

Is there a tool to autocrop and straighten scanned images?

Post by *mikedepetris »

I only find Photoshop tutorials or software that does only one of the two, but I remember I had the function in the HP scanner software.
I would like to take an image, mostly from scanner and automatically:
- straighten it, also known as deskew, rotate it
- crop it to the actual content, trimming borders

Some software is also able to recognize multiple images in a single scan, but this is too advanced, I would just like to autorotate&crop a single image, looking at the result, obviously it would be good to apply a batch transformation to a selected set of files.

And best of all of course, doing this in TotalCommander!
User avatar
nsp
Power Member
Power Member
Posts: 1345
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Is there a tool to autocrop and straighten scanned images?

Post by *nsp »

I personally use ImageMagick to do those tasks. From TC I have made a dedicated Graphical button bar using TCBL to process all selected file from regular folder. See some sample from TCBL tool wiki.
You can make as many command as you which in tcbl.ini file or have dedicated imagic in file.

Then you can create em/user command or button calling tcbl from TC using tcbl.ini scripts.

Code: Select all

cmd: <path to>\tcbl.exe
params:-i %L imagik.RotateLeft
Use convert.exe command instead of mogrify.exe for your test and add target file.
mikedepetris
Junior Member
Junior Member
Posts: 77
Joined: 2006-11-07, 16:36 UTC
Location: Trieste, Italy
Contact:

Re: Is there a tool to autocrop and straighten scanned images?

Post by *mikedepetris »

Can you help me with Imagemagick? I'cant find a way to rotate or crop the images AUTOMATICALLY.

In the while I found that you can do this with the batch actions of Xnview, and the MP version has even a preview. The trim/crop is not able to cut out all the margins even if I set maximum tolerance, but this is a minor problem.
User avatar
nsp
Power Member
Power Member
Posts: 1345
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Is there a tool to autocrop and straighten scanned images?

Post by *nsp »

What you want to achieve is probably OK with the following command:

Code: Select all

convert scan.jpg -fuzz "30%" -trim +repage -deskew "40%" scan_processed.jpg
I googled with some good words and found it here see latest post.

Do some test and adjust to your need..
If you want to do additional command you can add as many cmd entry as you need.

You can make a command entry in tcbl.ini

Code: Select all

[imagick.process_scan]
ini=q
# change to your imageMacick bin path
pre=set PATH=C:\tools\graphic\ImageMagick\;%PATH%
pre=set img_fz="30%"
pre=set img_dkw="40%"
cmd=convert "$f" -fuzz "%img_fz%" -trim +repage -deskew "%img_dkw%" "$z_processed.$e"
and then add a user command and/or a button manu entry .......

--edited code sample
mikedepetris
Junior Member
Junior Member
Posts: 77
Joined: 2006-11-07, 16:36 UTC
Location: Trieste, Italy
Contact:

Re: Is there a tool to autocrop and straighten scanned images?

Post by *mikedepetris »

great help thank you, experimenting I found that it is better to precede -deskew and then -trim, I still can't find a perfect trim of all borders, but it is enough by far!
Post Reply