How to deskew a scanned text-page with ImageMagick?

carbontracking picture carbontracking · Jan 9, 2017 · Viewed 9.1k times · Source

I have scanned documents that weren't scanned perfectly straight so the text is not orientated perfectly horizontally, i.e. perhaps 10° of a slop on each line.

My understanding is that the deskew option in imagemagick should solve this, for example

convert skewed_1500.jpeg -deskew 40% skewed_1500_not.jpg

but it doesn't have any noticeable effect on the output file.

I've attached the skewed/skewed_not images for comparison.

Best regards,

Colm

First the original image skewed image

Then the purportedly deskewed image deskewed image

Answer

Bonzo picture Bonzo · Jan 9, 2017

I would try a bigger value like 80% otherwise an Imagemagick forum member has a bash script that may be better: http://www.fmwconcepts.com/imagemagick/textdeskew/index.php