在 Gimp script-fu 中,如何访问 QuickMask 功能?

发布于 2024-12-20 20:37:18 字数 218 浏览 6 评论 0原文

在 Gimp GUI 中,QuickMask 对于​​很多事情都非常有用,但此功能似乎不能通过 script-fu 直接使用。在程序浏览器中我没有看到明显的等价物。

特别是,将图层的(值/灰色)像素放入选择蒙版中是我需要做的基本事情。我尝试使用 gimp-image-get-selection 获取选择通道的 id 号,然后 gimp-edit-paste 进入其中,但以下锚点操作导致 Gimp 崩溃。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱本泡沫多脆弱 2024-12-27 20:37:18

我的另一个答案包含“理论”的做法 - 然而,OP 在 GIMP 中发现了一个错误,从版本 2.6.5 开始,正如对该答案的评论中所示。

我得到了OP打算做的解决方法:将给定图像层的内容粘贴到图像选择中。如前所述,编辑-复制->在选择的可绘制对象上进行编辑粘贴会触发程序崩溃。

解决方法是通过复制粘贴方法创建一个包含所需内容的新图像通道,然后使用 gimp-selection-load 使选择内容等于通道内容:

因此需要调用的函数是(我赢了)不要粘贴方案代码,因为我不熟悉所有括号 - 我使用 GIMP 中的 Python 控制台进行了测试):

>>> 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)

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)
只有影子陪我不离不弃 2024-12-27 20:37:18

通过用户界面使用 QuickMask 与在选区上绘制完全相同,将选区视为可绘制对象。

因此,要在 script-fu 上使用“quickmask”的等效项,只需将 Selection 作为可绘制对象检索,并将其作为参数传递给将修改它的调用 -
要获得选择,只需调用“gimp-image-get-selection”

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'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文