Deskew is a tool for deskewing scanned text documents. Deskewing is a term used for fixing the scans to get the lines of text straight. That means rotating the image of the scanned page a little to compensate for the misalignment of the paper in the scanner.
Deskew uses Hough transform to detect “text lines” in the image and their orientation. As an output, you get an image rotated so that the detected lines are horizontal. You can find more theory in introductory post Deskewing Scanned Documents if you are curious.
At the moment, Deskew is a command line tool for Windows, Linux, and Mac. Based on the user feedback and my own usage, I’d say it works quite well 🙂 On occasion, I think about stuff like: GUI for Deskew, Deskew app for Android, Deskew web app, and even Deskew Photoshop plugin!
All Posts About Deskew
Downloads
Deskew 1.20
» 4.1 MiB - 7,967 hits - January 5, 2011 (last update November 1, 2016)
Command line tool for deskewing scanned documents. Binaries for several platforms, test images, and Object Pascal source code included.
Bugs Reports & Feature Proposals
Please report bugs and propose enhancements and new features in Deskew’s issue tracker: https://bitbucket.org/galfar/app-deskew/issues.
Source Code
Public Mercurial source repository of Deskew CLI tool is hosted at BitBucket: https://bitbucket.org/galfar/app-deskew.
I tried to use this amazing tool in ubuntu server 64 bit using deskew64 command line, I got the following error:
./deskew64: error while loading shared libraries: libtiff.so.5: cannot open shared object file: No such file or directory
Regards
Husam Haddad
Make sure you have libtiff5 package installed in Ubuntu (not libtiff4 or 3).
Thank you, actually I have Ubuntu Server 12.04, in order to include libtiff5 package I have to upgrade at least to Ubuntu Server 12.10.
Unfortunately, there’s tiny API change going from libtiff4 to libtiff5. Deskew can work with only one of them – so I chose the newer one.
Elegant, excellent. Thank you.
The precompiled ../Bin/deskew works flawlessly under Linux openSUSE 13.1 64-bit.
I’ll give you a plug on my site shortly.
Thank you again.
Cheers, Andy
Great to hear this, thanks.
As promised,
http://genietvanhetleven.blogspot.com/2014/06/easy-when-you-know-how-deskewing-text.html
Thanks again.
Cheers, Andy
Nice program to deskew an image. Is there an option to generate the output with no loss in quality ? I have noticed that JPEGs get compressed to lesser quality.
Cheers,
Arun
You can use PNG instead of JPEG as output format to get lossless result.
Tesseract OCR does not deskew pages and this makes a difference. I use xsane2tess.pl to call Tesseract from XSane. I edited my own version of xsane2tess.pl to include a deskew command. (Many thanks for Deskew!) My page http://www.d-meeus.be/linux/TesseractXSane.html is in French but you could guess… enough to download my own xsane2tess.pl.
Excellent tool.
Can i get 600 dpi resolution output. it’s my requirement.
You might can use this program to find your angle, then rotate using another method.
Can you explain how to simply find the angle but not rotate using this tool? Since I’m dealing with archival TIFFs I need to keep the DPI and embedded metadata in place, so I’m thinking I would use ImageMagick to rotate once I have the angle. Thanks.
For now you could use -l parameter:
-l angle: Skip deskewing step if skew angle is smaller
And use some large threshold so rotation will always be skipped.
$deskew -l 80 Sken003.png
...
Preparing input image (Sken003.png) ...
Calculating skew angle...
Skew angle found: 0.23
Skipping deskewing step, skew angle lower than threshold of 80.00
Done!
For next version I plan to modify this: angle is optional and if omitted rotation is always skipped.
Bug:
When deskewing images and converting from one format to another (for example, from jpg to tif) if the source image is not deskewed (rotation angle smaller than the default 0.01) then the source image is simply copied to the output image without conversion to the appropriate format, which results in files with wrong extension.
For example, running this command on an image that doesn’t need deskewing (can happen in batch files)
deskew -t 200 -o image_001.tif -b FFFFFF image_001.jpg
will simply copy image_001.jpg to image_001.tif WITHOUT actually converting it to TIFF format.
The workaround at the moment is to specify -l 0 or to convert every file to destination format prior to deskewing.
Other than this minor bug, deskew is an excellent program.
Thank very much.
Thanks for reporting this, will be fixed in the next release.
I just discovered this outstanding tool.
I am working for a non-profit organization operating a digitization shop. We are now in the process of scanning a lot of old newspapers, as well as old books, etc. After being created by the scanners, some image files are post-processed through a automated workflow using ImageMagick, LibTiff tools and Adobe Acrobat. Some originals are very difficult to align properly and their images come out with small amounts of skew, for example when the content does not properly align with the paper it is printed on. When viewed in the isolated, rectangular environment that a computer screen is, even small amounts of skew, in the order of little more than 0.1 degrees, are clearly visible and produce a bad impression on the reader.
Your tool is the first one giving us very satisfactory results. The deskewing function included in Acrobat does a mediocre job, often even tilting pages that previously were optically aligned. Your tool, with its very good deskewing, the possibility of setting a minimum threshold for deskewing, and the command line interface, is the ideal for the job.
Meanwhile, it has two aspects that I would like to modify by recompiling it:
— The density unit is defined in pixels per cm. Although this does not cause any problem in isolated images, I discovered that when the files rotated and not rotated by Deskew are combined in a multipage Tiff file, the rotated pages appear with a different size when imported into Adobe Acrobat. Either tiffcp or Acrobat (I can investigate which one later) gets confused by the mixing of units in different pages. I am using ImageMagick convert with the -units command to process the files after coming out from Deskew. It works but it is inelegant and introduces an additional step.
— Deskew compresses the modified images with LZW. Although this is alright for many purposes, it is unnecessary in our case and causes a small delay for each file, which can turn into a lot when we are talking about thousands of files in sequence. Although the ideal would be to chose the type of compression, including none, for now I would like to set the default to no compression.
I looked into the source files and I think I know where I can make the slight modifications mentioned above. So I tried to compile the code using Free Pascal but the build stops with the following error:
Linking Bin\deskew.exe
deskew.lpr(47,1) Error: Undefined symbol: __TIFFerrorHandler
deskew.lpr(47,1) Error: Undefined symbol: __TIFFwarningHandler
deskew.lpr(47,1) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
Although I often build software,I am not a programmer and my knowledge of these matters is very limited. When an error like this appears, I’m stuck. Although, of course, I can search for information, it would take a while, which is not compatible with my current enthusiasm with this tool. I really would like to further experiment with it.
Can you please give me some hint about what to do to solve this? Furthermore, I would like a Win64 build and I don’t know how to do it. Pascal is a complete stranger to me.
Thank you for offering us this very nice work. I don’t understand why a lot more people don’t know about it.
Best regards
Miguel
As we later discussed by email FPC version 3+ has some problems linking with precompiled LibTiff (Windows build). For time being use latest version of FPC 2 please.
This is now fixed so Deskew for Windows can be built with FPC 3+ as well.
Thank you. Excellent. I’,m newbie. Please help.
I have many thousands scanned .tif files, and I need a batch script .bat for this utility.
.Tif files exist in PICTURE1 folder, I’d like to run and deskewing files copy to PICTURE2 folder. How to write this script .bat ???.
This is a very great tool! Many thanks!
Using version 1.20 on Mac OS X 10.10.5, I noticed that deskewing .png files would result in output .png files, which are to a small degree blurrier than the original. This is a problem for me with low quality input files.
What can I do?
Cheers.
You could use Deskew just to find the skew angle and then rotate in some other program with better rotation output (ImageMagick maybe).
Thanks again for this great tool.
One issue I’m facing is when there is a small percentage of text on a page that is purposefully skewed (on a diagonal). Is there a way to ignore a percentage of lines of text if it’s below a certain threshold?
Here’s an example of a page that consistently gets deskewed at the wrong angle due to intentional diagonal text: https://www.dropbox.com/s/pvnpf890721z2h4/BAR_19931230_004.jpg?dl=0
Love the deskew tool, but I have noticed that it changes the dpi of all the images to 46dpi from 300dpi.
I do apologise. I have just done some tests and it isn’t the deskew tool that changes the dpi, it is the program I use to crop afterwards.