Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Which free software can I use to deskew scanned images

I have several PDFs made up of book pages' scans. The scans are made from two pages at a time and some of these scans are skewed, making text appear slightly tilted.

I'm looking for a tool that could allow me to do an automatic optimization by deskewing the scans without losing readability. I've found the GPL software briss to crop the scans in order to have a 1:1 page ratio instead of 2:1, but I don't have any tool to deskew the pages.

I stumbled upon unpaper, another open source tool that seems perfect for what I want to do, but that tool is Linux only and it doesn't work on PDF files directly.

Any hint is appreciated.

share|improve this question

marked as duplicate by random Jul 8 '12 at 3:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@random: Why has this question been closed?? Why should this topic solicit 'debate, arguments, polling or extended discussion'?!? – Kurt Pfeifle Jul 8 '12 at 0:40
"looking for a tool" is pretty much polling for services leads to the not constructive close reason @kur – random Jul 8 '12 at 0:43
@random: This question led me to do some research about the topic, and I found some interesting options to persue. The most interesting one is using ImageMagick for this, and it seems surprisingly simple. Unfortunately your closing of this does not allow me to post my answer. – Kurt Pfeifle Jul 8 '12 at 0:58
@random: I'v now edited the question a bit. Hopefully it is now more compliant to your sense of 'constructiveness'. – Kurt Pfeifle Jul 8 '12 at 1:50
@random: Ok, 'closing as duplicate' is better acceptable to me in this case. – Kurt Pfeifle Jul 8 '12 at 10:00

Have a look at deskew. It's a commandline tool. The download *zip seems to include binaries for Windows, MacOSX and Linux.

License is MPL (Mozilla) or LPGL (GNU), whatever you prefer.

The only drawback for you seems to be that it doesn't consume PDFs, only PNG and TIFF images (AFAICS). That means you'll have to set up a workflow of like:

 PDF.orig -> PNG.orig -> PNG.deskewed -> PDF.deskewed

I haven't tested it myself (yet), I just came across the website recently and bookmarked it.

share|improve this answer
deskew did manage to correct rotation-related distortion in my test run but unfortunately it introduced a thin gray line at the position of the original image border. To get rid of the gray border I cropped the images with the -extent option of mogrify. I only tested on OS X, maybe this misbehaviour is platform-specific. – Stefan Schmidt May 25 '15 at 19:45

Oh, let me add another answer. I just remembered netpbm. Haven't used it in years, but I think I should take a fresh look...

netpbm is a very powerful toolkit for the commandline to manipulate of graphic images. It ships nearly 300 separate tools. It includes converters for about 100 graphics formats.

And it also has a commandline tool that can rotate images:


And it has another tool that tries to discover the angle of rotated images:


pamtilt returns a floating number of its guess of image rotation. So the automatic de-skewing of images should be within reach. A shell script could be written to do that. It would require different steps:

  1. Convert PDF page to an netpbm-suitable image format with the help of Ghostscript.
  2. Use pamtilt to auto-discover the skew angle of the image.
  3. Use pnmrotate to de-skew the image.
  4. Re-convert the image to PDF.

If you provide me access to a small sample of your PDF files I could try and come up with a shell script to accomplish the feat.

(I'm wondering heavily that [netpbm] doesn't seent to have a tag here on the superuser+stackoverflow.)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.