- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试为 GIMP 编写一种包装器库以使我的生成艺术项目更容易,但我在从我的包装器模块连接 gimpfu 时遇到问题。下面的插件代码运行良好,并显示一个图像,上面画有水平线:
from gimpfu import *
from basicObjects import *
def newFilt() :
img = gimp.Image(500, 500, RGB)
background = gimp.Layer(img, "Background", 500, 500,RGB_IMAGE, 100, NORMAL_MODE)
img.add_layer(background, 1)
background.fill(BACKGROUND_FILL)
pdb.gimp_context_set_brush('1. Pixel')
pdb.gimp_context_set_brush_size(2)
for i in range(100):
Line= line([(0,5*i),(500,5*i)])
pdb.gimp_pencil(background,Line.pointcount,Line.printpoints())
gimp.Display(img)
gimp.displays_flush()
register(
"python_fu_render",
"new Image",
"Filters",
"Brendan",
"Brendan",
"2016",
"Render",
"",
[],
[],
newFilt, menu="<Image>/File/Create")
main()
'line' 类在 basicObjects 中定义,并且按预期运行,但是如果我尝试将 'pdb.gimp_pencil(background,Line.pointcount,Line.printpoints())' 替换为 'Line.draw(background) )', 并在线类中添加一个 draw() 函数,如下所示:
from gimfu import *
class line:
"""creates a line object and defines functions specific to lines """
def __init__(self, points):
self.points = points
self.pointcount = len(points)*2
def printpoints(self):
"""converts point array in form [(x1,y1),(x2,y1)] to [x1,y1,x2,y2] as nessecary for gimp pdb calls"""
output=[]
for point in self.points:
output.append(point[0])
output.append(point[1])
return output
def draw(self,layer):
pdb.gimp_pencil(layer,self.pointcount,self.printpoints())
图像未渲染,gimp 错误控制台中未显示任何消息。如何从外部文件进行 pdb 调用?使包装器成为一个单独的插件会有所帮助吗?
最佳答案
首先:gimp 和 gimp-fu 模块仅在 Python 脚本作为插件从 GIMP 中运行时才起作用。我不知道你所说的“外部文件”是什么——但入口点总是一个插件脚本。它可以像任何普通程序一样导入其他 Python 模块。
第二:GIMP 插件运行的是 Python 2.x(现在是 2.7)——因此任何声明的类都应该继承自 object
——声明一个类而不像你那样继承自 object 会只会给您带来意想不到的问题 - 虽然这可能不是您现在的问题。
类声明看起来不错,但您调用它的示例不是 - Line.draw(background)
似乎表明您正试图在类本身而不是实例上调用方法您的 line
类。
关于python - 从外部模块调用 gimp-fu 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37082954/
我正在尝试在 GIMP 中编写一个脚本,该脚本将加载 PNG 文件并以最大压缩率再次保存它(我还计划添加其他处理步骤)。然而,以下脚本似乎破坏了 alpha 信息: (define (process-
在 Vim 中交换方法调用的两个参数的最有效方法是什么? 例如我要更改: call "hello mister 123", 2343 至: call 2343, "hello mister 123"
我正在尝试编写一个脚本,将一个图层切成小块。它运行正确,但没有任何内容粘贴到新层中。 def explode_layer( i, l, dx, dy ): T=[] for ix,ox
我是 python-fu 的新手,(我的第二天),所以我的问题可能看起来很幼稚:我想从“r400r.png”中选择一个矩形部分,将其旋转 90 度,然后保存我的在“r400ra.png”中选择。 到目
以下是我正在尝试编写的较大 Script-fu 脚本的一部分。 我在尝试复制打开的 .xcf 文件然后将其缩放到某个用户指定的维度时遇到了问题。 以下是我认为可行的方法: (define (my-du
我打开了不止一张图片,我想对当前选中的图片运行 scrip-fu 函数。如何获取当前所选图像的图像引用编号,以便我可以在其他函数中使用该引用(例如 (gimp-image-width 7))?我正在使
这个小程序可以找到文件中最常用的十个单词。您或您将如何优化它以通过逐行流处理来处理文件,但保持其现在的功能风格? static void Main(string[] args) {
我似乎无法在 python-fu 界面的任何地方找到任何将一个组层添加到另一个组层的方法。 我也尝试在 Gimp.Layer 对象上寻找方法,但没有成功。 如何使用 python-fu 将一个图层组添
这里是 Linux。我正在尝试对我的文件系统上的任意目录运行某种 shell-fu 命令,并让它吐出该目录中包含至少一个实例的所有文件(递归搜索)一个特定的(引用的)短语。所以像这样: someMag
我正尝试按照 GitHub 页面上的说明构建 Droid-Fu,但构建失败。这是我在 Droid-Fu 文件夹中运行 mvn package 后得到的消息 [INFO] artifact junit:
我正在尝试实现 Bin Fu's approximate sum algorithm用真实的语言更好地了解它的工作原理。 In a nutshell ,这是一个计算 $\hat{s}(x)$ 的算法,
我正在编写一个插件脚本,它将打开一个文件,按颜色选择,将选择更改为新颜色,将图像另存为新文件。 我不知道如何将颜色更改为新颜色。有人可以提供指导吗? 这是我目前所拥有的: # open input
我觉得这应该是一个简单的答案,但我完全被难住了。 我已将 mimetype_fu 添加到我的 gemfile 中,并在运行捆绑安装时安装了它。当我尝试使用 File.mime_type 时?在我的应用
问题 我需要在图像上进行数百次多边形选择。为了提供帮助,我一直在尝试使用 python 控制台创建一个脚本,该脚本将以计算的方式执行此操作(相同大小的区域,数百个不同的起点)。我在 Windows 1
我去过Gimp: python script not showing in menu这对我没有帮助。这是我一步一步尝试的: 1. 我在 Mac OS X 10.9.5 上从命令行运行 Gimp 2.8
我在通过 GIMP 在 python 中保存图像时遇到问题。我可以获得图像并应用我想要的效果,但是当我去保存时,它只保存一层而不是所有内容(注意:背景是透明的)并且因为背景是透明的,所以我无法保存任何
我正在尝试为 GIMP 编写一种包装器库以使我的生成艺术项目更容易,但我在从我的包装器模块连接 gimpfu 时遇到问题。下面的插件代码运行良好,并显示一个图像,上面画有水平线: from gimpf
(define (script-fu-create-camo image colA colB)) (script-fu-register "script-fu-create-camo"
我正在尝试实现 Bin Fu's approximate sum algorithm用真实的语言更好地了解它的工作原理。 In a nutshell ,这是一种算法,可以有效地计算 $(1+\epsi
我正在编写一个扫描器作为编译器的一部分。 我在写这一部分时非常头疼: 我需要能够解析标记流并将它们一个一个地插入 vector ,忽略空格并标记特殊符号(简单情况,让我们只考虑圆括号和大括号) 例子:
我是一名优秀的程序员,十分优秀!