[vox] pnmthreshcrop

Bill Kendrick vox@lists.lugod.org
Sun, 14 Dec 2003 02:54:54 -0800


Someone doing some astronomical photography on the Gimp usenet newsgroup
was asking if there was an easy, batch-able way to crop a ton of photos
so thast only the 'interesting' part (in his case, the planet Mars, which
appaeared in different parts of the photos, as it moved across the sky).

I suggested "pnmcrop", which is one of the NetPBM console-based tools.
It lets you say "the part I don't care about is black... remove all black
border."

Unfortunately, it appears you can't provide a threshold, and since his photos
wound up as JPEGs (or imagine if faint stars appeared here and there),
there were slight variations of "black" in the images, and therefore nothing
would get cropped out.

So, I whipped together a tiny NetPBM-library-based C program that tries
to crop out black, but allows you to specify a threshold.  (In his case, "6"
was the magic number to get the black around Mars to go away.)

I've released it as GPL.  You can also consider it a simple example of how to
program libnetpbm.  (The man page kinda... sucks)

  ftp://ftp.sonic.net/pub/users/nbs/unix/console/pnmthrescrop/

-- 
bill@newbreedsoftware.com                           Got kids?  Get Tux Paint! 
http://newbreedsoftware.com/bill/       http://newbreedsoftware.com/tuxpaint/