by Marek Mauder
https://galfar.vevb.net/deskew
https://github.com/galfar/deskew
v1.30 2019-06-07
Deskew is a command line tool for deskewing scanned text documents. It uses Hough transform to detect "text lines" in the image. As an output, you get an image rotated so that the lines are horizontal.
There are pre-compiled binaries built for these platforms (located in Bin folder):
Win64 (deskew.exe), Win32 (deskew32.exe), Linux x86_64 (deskew), macOS x86_64 (deskew-mac), Linux ARM aarch64 (deskew-arm64) and v7 (deskew-arm).
GUI frontend for this CLI tool is available as well (Windows, Linux, and macOS), see GUI's Readme.
License: MPL 2.0
https://github.com/galfar/deskew/releases
https://galfar.vevb.net/deskew#downloads
Usage:
deskew [-o output] [-a angle] [-b color] [..] input
input: Input image file
Options:
-o output: Output image file (default: out.png)
-a angle: Maximal expected skew angle (both directions) in degrees (default: 10)
-b color: Background color in hex format RRGGBB|LL|AARRGGBB (default: black)
Ext. options:
-q filter: Resampling filter used for rotations (default: linear,
values: nearest|linear|cubic|lanczos)
-t a|treshold: Auto threshold or value in 0..255 (default: a)
-r rect: Skew detection only in content rectangle (pixels):
left,top,right,bottom (default: whole page)
-f format: Force output pixel format (values: b1|g8|rgb24|rgba32)
-l angle: Skip deskewing step if skew angle is smaller (default: 0.01)
-g flags: Operational flags (any combination of):
c - auto crop, d - detect only (no output to file)
-s info: Info dump (any combination of):
s - skew detection stats, p - program parameters, t - timings
-c specs: Output compression specs for some file formats. Several specs
can be defined - delimited by commas. Supported specs:
jXX - JPEG compression quality, XX is in range [1,100(best)]
tSCHEME - TIFF compression scheme: none|lzw|rle|deflate|jpeg|g4
Supported file formats
Input: BMP, JPG, PNG, JNG, GIF, DDS, TGA, PBM, PGM, PPM, PAM, PFM, TIF, PSD
Output: BMP, JPG, PNG, JNG, GIF, DDS, TGA, PGM, PPM, PAM, PFM, TIF, PSDFor TIFF support in Linux and macOS you need to have libtiff 4.x installed (package is usually called libtiff5).
For macOS you can download prebuilt libtiff binaries here: https://galfar.github.io/store/TiffLibBins-macOS.zip. Just put the files inside the archive to the same folder as deskew-mac executable.
On ARM targets linking to libtiff is disabled at the moment (known
to crash with deskew). If you want to try yourself enable it in ImagingTiff.pas unit.
You can find some test images in TestImages folder and
scripts to run tests (RunTests.bat and runtests.sh) in Bin.
By default scripts just call deskew command but you can pass a different one as a parameter
(e.g. runtests.sh deskew-arm).
File them here:
https://github.com/galfar/deskew/issues
v1.30 2019-06-07:
v1.25 2018-05-19:
v1.21 2017-11-01:
v1.20 2016-09-01:
v1.10 2014-03-04:
v1.00 2012-06-04:
v0.95 2010-12-28:
v0.90 2010-02-12:
Deskew is written in Object Pascal. You need Free Pascal or Delphi to recompile it.
There are project files for these IDEs:
Additionally, there are compile shell/batch scripts for standalone FPC compiler in Scripts folder.
Deskew can be compiled and was tested on these platforms: Win32, Win64, Linux x86_64, macOS x86_64, Linux ARM aarch64 + v7.
Latest source code can be found here:
https://github.com/galfar/deskew
Vampyre Imaging Library is needed for compilation and it's included in Deskew's repo in Imaging folder.