Python#u-fu插件赢得';gimp中的t负载

Python#u-fu插件赢得';gimp中的t负载,python,gimp,gimpfu,Python,Gimp,Gimpfu,我正在尝试使用python_-fu编写一个gimp插件。我希望它采取许多相同大小的层,并把他们在一条垂直线。这将用于打开pdf文件,其中每个页面占据一层,插件将它们排成一行。但当我运行插件时,菜单中没有显示任何内容。当我注释掉上面带有星号的行时,插件会加载到菜单中 %UserProfile%\.gimp-2.8\plug-ins\Array.py from gimpfu import * def plugin_main(timg, tdrawable, widthNum, heightNum)

我正在尝试使用python_-fu编写一个gimp插件。我希望它采取许多相同大小的层,并把他们在一条垂直线。这将用于打开pdf文件,其中每个页面占据一层,插件将它们排成一行。但当我运行插件时,菜单中没有显示任何内容。当我注释掉上面带有星号的行时,插件会加载到菜单中

%UserProfile%\.gimp-2.8\plug-ins\Array.py

from gimpfu import *

def plugin_main(timg, tdrawable, widthNum, heightNum):

    layers = gimp-image-get-layers(timg) #<< Gets a list of all the layers

    #Sets the WIDTH and HEIGHT to the size of the first image
    WIDTH = layers[0].width
    HEIGHT = layers[0].height

    #Loops through all layers and moves them
    for i in range(layers.length):
        location = float((i+1)*HEIGHT)
        #*****
        transformedimage = gimp-item-transform-2d(layers[i], 0.0, 0.0, 1.0, 1.0, 0.0, location) #<< When I comment this line out the plugin loads

    gimp-image-resize-to-layers() #<< Resizes the image to fit the moved layers

register(
        "python_fu_array",
        "Sets out your layers as tiles",
        "Sets out your layers as tiles",
        "author",
        "author",
        "2016",
        "<Image>/Image/Array",
        "RGB*, GRAY*",
        [],
        [],
        plugin_main)

main()
从gimpfu导入*
def插件_main(timg、tdrawable、widthNum、heightNum):

layers=gimp-image-get-layers(timg)#例如,看看一些现有的基于Python的插件

注意一些过程是如何调用的,例如在第168行:

您的代码有两个不同之处:

  • pdb前缀
  • 下划线而不是连字符/减号

  • 将插件更改为这样做,您将获得进一步的步骤。

    除了Michael的评论之外,Python fu接口通常可以避免使用pdb.*函数。例如,要迭代图像层:

    您的代码:
    layers=gimp image get layers(timg)#必须完全清楚:
    gimp-item-transform-2d
    在Python中意味着一系列减法,而不是变量名。Python中的GIMP api名称替换了
    \uuuu
    -
    。它们位于
    pdb
    命名空间中-因此-将有问题的行更改为包含
    pdb.gimp_item_transform-2d(…)
    ,而不是当前的表单。只是另一句话-这种交互层的方式不再好,因为它不考虑图层组。我在SE上的某个地方写了一些关于如何进入图层组的帖子。@jsbueno在一般情况下是的,但在许多情况下它已经足够好了。整个脚本看起来需要一个特定的层设置。
    temp_image = pdb.gimp_image_new (...)
    
    #Sets the WIDTH and HEIGHT to the size of the first image
    WIDTH = layers[0].width
    HEIGHT = layers[0].height
    
    #Loops through all layers and moves them
    for i in range(layers.length):
    
    # better use the image height/width, layer h/w can be different
    width=image.width
    height=image.height
    
    for position,layer in enumerate(image.layers):
        # etc....