Sunday, October 7, 2012

Something I want to do with gimp

But don't know how.

Gimp has various useful tools:
It has select by color.
It has invert selection.
It has shrink selection. (with options to shrink from image border or not)
It has save a selection to path
It has load a selection from path
It has fill by color.

What I want do do with it, in pseudo-code because I haven't coded in forever remember little if anything, is this:

User inputs integer A, which is greater than or equal to 1.

SubThing(Int X, Path){
int Z==X/1 (rounding down)
int J==1

Fill white

For{int stop==0; stop=0;}
Selection from Path
Shrink selection by Z (not from border)
If selection nonexistant {stop==1
Else  {If J=0  {Fill white; J==1
else  {Fill black; J==0

Main(int A){
Select Black
Path == Selection to Path

Subthing(A, Path)

Selection from Path
Invert selection
Path == Selection to Path

Subthing(A, Path)


Or something like that, it's been ages since I looked at code.

Anyway, trouble is I have no idea how to do it.

Anyone able to help?

On further examination, saving the selection to a channel might be a better ideal for reasons I don't fully understand but none the less appear to be real


  1. It certainly ought to be possible, but I've never done any coding for the Gimp. What's your (or its) preferred language?

    1. The only language I ever learned was Java, which I learned by taking one class in it years ago.

      It has support for python but I'm pretty sure it's not actually built in that, I think it's written in C, but I'm not sure. It also has something called "script fu" which is apparently scheme based.

    2. OK, looks as though C/Python/Scheme[Script-fu] are the first-class citizens of the Gimp scripting world. I speak C but I don't want the faff, and I don't like Python, so I'll probably look at Scheme. Time I learned a new language anyway!