Deskew Tools

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,330 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.

22 thoughts on “Deskew Tools

  1. 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

      • 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.

  2. 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

  3. 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

      • 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.

  4. 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.

  5. 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.

  6. 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 ???.

  7. 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).

Leave a Reply

Your email address will not be published. Required fields are marked *