Wednesday, April 17, 2013

Trim surrounding whitespace from pictures

I was scanning some old pictures lately, and noticed - only after 200 scanned pictures, of course - that they were surrounded by white space, to fill them up to the size of an A4 paper.

Well, there's only one thing one can do in this situation: write a script which trims pictures from surrounding whitespace. You can find the script here:

As this script is written for bash, it only works on Linux systems. I guess there's some nasty way to get bash running on Windows too, but hardly anyone still uses Windows nowadays, right? Moreover, you need ImageMagick installed.

If all of the above applies to you, you can run the script like this:
 whitespace_trimmer DIRECTORY_TO_BE_TRIMMED

In case you're curious what the pictures I needed to be trimmed looked like, here's one of them:
Sample picture to be trimmed

No comments:

Post a Comment