0

In the Gimp GUI, the QuickMask is very useful for many things, but this functionality doesn't seem to be directly available through script-fu. No obvious equivalents were apparent to me in the procedure browser.

In particular, putting the (value/gray) pixels of a layer into the selection mask is the basic thing I need to do. I tried using gimp-image-get-selection to get the selection channel's id number, then gimp-edit-paste into it, but the following anchor operation caused Gimp to crash.

mgkrebbs
  • 856
  • 15
  • 22

2 Answers2

1

My other answer contains the "theoretical" way of doing it - however, the O.P. found a bug in GIMP, as of version 2.6.5, as can be seem on the comments to that answer.

I got a workaround for what the O.P. intends to do: paste the contents of a given image layer to the image selection. As denoted, edit-copy -> edit-paste on the selection drawable triggers a program crash.

The workaround is to create a new image channel with the desired contents, through the copy and paste method, and then use gimp-selection-load to make the selection equal the channel contents:

The functions that need to be called are thus (I won't paste scheme code, as I am not proficient in all the parenthesis - I did the tests using the Python console in GIMP):

>>> img = gimp.image_list()[0]
>>> ch = pdb.gimp_channel_new(img, img.width, img.height, "bla", 0, (0,0,0))
>>> ch
<gimp.Channel 'bla'>
>>> pdb.gimp_edit_copy(img.layers[0])
1
>>> pdb.gimp_image_add_channel(img, ch, 0)
>>> fl = pdb.gimp_edit_paste(ch, 0)
>    >> fl
<gimp.Layer 'Pasted Layer'>
>>> pdb.gimp_floating_sel_anchor(fl)
>>> pdb.gimp_selection_load(ch)
jsbueno
  • 99,910
  • 10
  • 151
  • 209
0

Using QuickMask through the User interface is exactly equivalent to draw on the Selection, treating the selection as a drawable object.

So, to use the equivalent of "quickmask" on script-fu all one needs to is to retrieve the Selection as a drawable and pass that as a parameter to the calls that will modify it - And to get the selection, one just have to call 'gimp-image-get-selection'

jsbueno
  • 99,910
  • 10
  • 151
  • 209
  • As I hinted in the question, this isn't working for me. Using GIMP 2.6.5, I do this in a grayscale image: gimp-selection-all, gimp-image-get-selection, gimp-edit-copy[thelayer], and gimp-edit-paste[sel channel]. At this point, a call to gimp-floating-sel-anchor will crash Gimp with a trap. If instead I simply finish the script, the GUI shows a floating selection which can't be put into a layer (says attached to channel (OK)), traps GIMP if anchored, and acts very oddly if anything else is attempted. – mgkrebbs Dec 14 '11 at 19:59
  • Can you please open a bug for this at bugzilla.gnome.org ? In that way all active GIMP developers will be aware of it. – jsbueno Dec 15 '11 at 00:03