Page 1 of 1

Batch Processing in Gimp?

Posted: 02 Mar 2011, 01:47
by umpausewhat
Hi all,

I'm trying to come up with a script (or plug-in) for gimp that will batch process my jpegs to correct for barrel distortion and am wondering if any of you program in scheme. Gimp has a plugin for correcting barrel distortion, so I'm hoping it's not too complicated to ask gimp to run this process with uniform parameters on a set of files. Not knowing much of anything about programming, I've tried to adapt other scripts I've found on the internet to suit my purposes, but I haven't made anything work yet. Just thought I'd check here in case any of you would also have use for such a script and might be able to write it with minimum inconvenience. Sample batch scripts/plug-ins can be found in the gimp registry (http://registry.gimp.org/); I've also tried to adapt the script found here: http://www.gimp.org/tutorials/Basic_Batch/.

I know this won't be of use to everyone, but with a bkrpr build, it would theoretically work well insofar as the camera is always the same distance from the page and thus, I'm guessing, the barrel distortion is uniform for all the pictures. The downside of the bkrpr build is that barrel distortion is, in my experience, unavoidable. The distortion isn't bad for books under 8.5 inches tall, but much beyond that, it becomes distracting. If gimp could be used to correct for this, I think my scanning process would finally be optimized.

I'm using Windows Vista, if that makes a difference. If I end up finding a way to make it work, I'll post my results here. If any of you think you can accomplish this easily, I'd be grateful.

Re: Batch Processing in Gimp?

Posted: 02 Mar 2011, 01:51
by steve1066d
You may want to take a look at Bookscanwizard, as it can correct for barrel (as well as perspective) distortion.

Re: Batch Processing in Gimp?

Posted: 02 Mar 2011, 02:56
by daniel_reetz
Seconding BSW, it's being built from the ground up to be the ideal software for this kind of application.

Re: Batch Processing in Gimp?

Posted: 02 Mar 2011, 10:09
by Anonymous1
I used the GIMP for batch autocropping, but I've found that ImageMagick can do everything that GIMP can:

Code: Select all

convert foo.png -fill white -box "Red" -gravity South -pointsize 20 -annotate +0+5 "Foobar" foo.jpg
I'd also use BSW. Steve's really good with all this image-processing stuff.

Re: Batch Processing in Gimp?

Posted: 02 Mar 2011, 13:46
by umpausewhat
Thanks for the quick replies. I'm trying to install BSW, but am having some trouble (I posted my problem in the BSW thread). If I understand what BSW does, my only qualm is that my bkrpr build does not ensure that the book page will occupy the same position in every picture, so auto-cropping might not work in making all the pages look uniform. I might still need Scan Tailor's detection capabilities. But if BSW will allow me to just correct for the barrel distortion, I could do the rest in Scan Tailor.

I'll look more into ImageMagick, but at first blush, it seems just as intimidating as finding out a scheme script for GIMP.

Re: Batch Processing in Gimp?

Posted: 02 Mar 2011, 14:01
by steve1066d
Yes, that's one of the advantages of ScanTailor.. because it processes each page individually, you can potentially get less movement from page to page if the book moves from page to page (though it does take longer).

Be sure to create the tiff files with no compression if you do use BSW with Scan Tailor (BSW & Scan Tailor don't have a compatible way of handling compressed images).

As far as a process of using both BSW & Scan Tailor, I'd recommend you do fix the barrel distortion, perspective distortion, and do a rough crop in BSW (if necessary), then do the rest of the processing in Scan Tailor.

Re: Batch Processing in Gimp?

Posted: 16 Mar 2011, 02:17
by scribbleed
I just would like to chip in (my first post!).

Have a look at http://hugin.sourceforge.net/, with which you could fine tune your barrel distortion correction (see tutorials). It does have a batch process function (I think you need to switch off panorama stitching), but I am not sure if you can invoke it without starting the program, if that is what you want. But once you have the a,b,c,d, parameters (use a grid picture), I think you can try to find the original http://panotools.sourceforge.net/ program, PTOptimizer, which should work from the command line.

On a related note, UFRaw, which Gimp uses, gets information from the LensFun library, so it might just have your camera configuration (http://ufraw.sourceforge.net/lensfun.html). Not sure how to invoke that from a script though.