Pages

Thursday, July 19, 2012

Can someone who knows programming help me out with gimp?

So, gimp.  In theory I can program plugins to do things that are tedious yet simple for me thus cutting out the whole "tedious" part.  The trouble is that this rests on, "In theory I can program."

In theory I can program.  I have learned how to do bits and pieces (in other programming languages, but still) in the past just by having an idea and trying to run with it to the best of my ability and learning in the process.  And I'm definitely capable of learning.  But, in this case, in practice I'm more staring at things and having no idea where to start.

So one thing that I've been thinking would be useful would be the ability to create what I think is known as a (user level) macro.  I've not used them before, I solved the four dimensional Rubik's cube making every turn manually, but being able to tell the program, "Pay attention," do several things, and then tell it, "See what I just did?  I want you to do it again every time I hit [key]" would be useful.

That's not why I'm writing this post, though.

There's a series of things that I've been wanting to do and I realized that a good first step for most of them would be able to, basically, select a color and then, for all the pixels within said color, if they're a given distance from the edge, turn them to another color.  The given distance would sometimes be a straight integer, more often be an equation, like [6X +/- .5] or [ -6 + 36.5X +/- 12].

Recently I've realized that it seems like basically everything needed for such a thing is already in gimp.  There is a tool that specifically exists for the purposes of selecting a given color, I already knew that.  There is a function to shrink the selection by a given distance, which seems like it has to work by checking pixels and saying, "Are you [given distance] from the existing selection border?" and then when the answer is yes making it into the new border.  Obviously there's some margin of error since pixels will rarely be integer distances from other pixels.  (That margin of error becomes extremely apparent if you compare two selections that started off the same and were shrunk the same amount, but one was shrunken as a series of steps where the other done as a single step)

So it seemed like I'd just have to look at how that worked, modify it a bit, and I'd have my thingy.

I can't even figure out where the code for that is stored.

-

Now what's there as is does actually allow for me to get what I would want, but to avoid that snowballing error mentioned in the parenthetical above what it would mean would be selecting by color (which can slow things down a lot since it creates really complex selections), saving the selection, shrinking, filling with one color, loading the selection, shrinking by a different (larger) amount, filling with another color, loading the selection, shrinking by a different (larger) amount, filling with the first color, loading the... and that could take all day if not longer.

Annoying as all hell and not something I'm going to spend my time doing.

Can anyone out there tell me how to get what I want?  It seems like the place to start might be the shrink selection code, I don't even know where to find it.  Or how to find it.

-

On the subject of not knowing how to find code, I'd like to be able to take a closer look at the mosaic distort and try to apply the interpolation functions to other contexts, but I don't even know how to navigate.  I can find a thing that says, "The source code is online here,"* but apparently it's assumed one already knows how to find what they're looking for once they get to the place where the entire program's source code is stored.

-

Technically it says, "You can browse the source online."

4 comments:

  1. In my experience, you're not going to get very far browsing source online unless you're already very familiar with the particular project in question.

    Really the only way to look for what you want is to download the full source code and either use "grep" if you're familiar with that tool or load it into an IDE with a good search function. If you don't have a preferred IDE, you could probably try Eclipse - there's a specific download for C/C++ development.

    Then search for things like "shrink" or "mosaic".

    ReplyDelete
  2. But you shouldn't need to edit the actual GIMP source code. It would be a plugin or macro of some kind. I'm not at all familiar with any form of image-editing software, but this might already exist somewhere. One place to ask would be Super User. There's a lot of very geeky people there who would know where to direct you.

    TRiG.

    ReplyDelete
  3. For working with the code, you'd probably need to be familiar with the GIT version control software. Version control manages the history of the project. It can also include branches and merges. (Version control software differs, but GIT makes it easy to branch and merge to solve problems.) People working on one problem will take a branch and edit it till the problem is fixed, then merge that branch back into the trunk. And every so often whatever's in the trunk is released as an update to the project (GIMP).

    So the simplest way to get hold of the source code is probably to install GIT on your computer, and then run git://git.gnome.org/gimp to get your own copy of the code.

    That's if you want to work with the code. Working with it within GIT would allow you to submit your changes back to the project. The project leaders could then look at the branch you'd created, and decide whether to merge it into the trunk.

    On the other hand, if you just want to look at the code, there should be a simple download link somewhere, but I cannae find it. All I can see a lot of diffs.

    TRiG.

    ReplyDelete
  4. A late addendum to this: if you already have a chosen programming language, you may well find there's a decent image manipulation module already available for it, on which you can build your own code. For example, I am a fan of Perl's Imager module.

    ReplyDelete