Sometimes I need to process scanned images or photographed book covers, where I usually only have the resulting image (JPG/PNG) but not the original (to recreate a clean variant myself). Pages/covers are not always correctly aligned, which is the hardest task of post-processing for me currently: it's a complicated job in Gimp using the "perspective tool", as I've found no alternative to that yet.

Seeing scanning apps on Android, it should be pretty easy to adjust/align such a scanned page:

CamScanner Mobile Doc Scanner YouCam
Screenshots from CamScanner / Mobile Doc Scanner / YouCam (click images for larger variants)

As the screenshots show, you basically tap the 4 corners of the paper (or rather adjust the "grid" to match them), tap the check-mark in the toolbar (at the bottom), and have the page adjusted.

What's possible on some smartphone with Android shouldn't be too hard to accomplish on a more powerful desktop machine. Nevertheless, either my Google-Fu isn't good enough or there doesn't seem to be a corresponding application.

Summing up my requirements:

  • must run on Linux (Java applications acceptable, Gimp-addons welcome)
  • must be free (as in "free beer" – open-source would be an added plus)
  • easy to install (not too many dependencies)
  • easy to work with (basically, as easy as it is in mentioned Android apps)
  • can be stand-alone or an addon for Gimp

3 Answers 3


There is a cross platform solution for Windows, OS-X, Linux & Android which uses a combination of:

It is:

  • Free
  • Open Source
  • Cross Platform
  • Not too many dependencies
  • Even easier to work as it doesn't even require you to select the corners it finds them for you providing there is a reasonable contrast in the image.

And it is all spelt out, complete with source code at: http://www.pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/ by Adrian Rosebrock.

I am not going to reproduce the code here as there might be copyright issues with doing so but you are free to use the code which comes to about 70 lines of python from the blog post plus another 30 from a referenced post.

  • 1
    Thanks, Steve – that'd be something to start with. But I rather was hoping for a ready-to-use solution (not something I need to write myself, as good examples as are provided) – and rather dislike giving them my email address just to download those examples. Also I see I should have been more exact on what "not too many dependencies" is supposed to mean: installing 5 "kits" and then writing my own code is not what I had in mind :) Good find, though – so +1 from me. Hoping for something easier, though :)
    – Izzy
    Jul 17, 2016 at 17:59
  • If you had over your email you get the complete program, I just did it. You do, however, still need to install the dependencies. I tested it on a small group of images, and if the image contains a square it make lock onto a small potion of the document and only give you that. It is far from perfect, and only a few minor calibrations can be made.
    – cybernard
    Jul 18, 2016 at 2:20

I have been playing with the nightly builds of Gimp 2.9 and it features a new perspective transform tool which when applied to one of your samples gives:

enter image description here -> enter image description here

So Keep your hopes up - Screenshot of it in action: enter image description here

Or risk the nightly builds!

  • Good find, Steve – thanks! That's more like it. Though it means waiting for Gimp 2.10 then (odd numbers are dev builds with Gimp). I wish there was an easy way to install that as "portable" on Linux, so one could use it along the stable version. But I'm not sure if it's the same: That's the tool I'm currently using – and your screenshot doesn't look like one just marks the 4 corners and Gimp transforms that to an rectangle. It rather looks like what I have to do now: manually dragging the corners until it fits?
    – Izzy
    Jul 18, 2016 at 6:38
  • @Izzy - It is true that you still have to drag the corners but it is a lot easier to use than the older perspective tools. If you are prepared to build gimp from source then wiki.gimp.org/wiki/Hacking:Building/Linux explains how to build and install it without interfering with your existing gimp. Jul 18, 2016 at 6:58
  • Thanks, Steve – I might have a look into that – though I'm certain I run into dependency issues concerning "too old libs", still being on Ubuntu 12.04, so I most likely have to postpone that until I found time to setup a new system. So I'll first wait if something more convenient shows up :)
    – Izzy
    Jul 18, 2016 at 7:08

Thanks @Steve. This is cool feature from GNU Gimp. Here goes my work flow. This'll help future readers.

  1. Shift+P - Open perspective tool & adjust the image , their corners
  2. Shift+Ctrl+C - Copy Visible into memory
  3. Shift+Ctrl+V - Open new image with transformed image from memory
  4. Shift+Ctrl+E - Export the final output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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