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

%UserProfile%\。gimp-2.8 \ plugins \ 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()

最佳答案

看一下一些现有的基于Python的插件,例如https://git.gnome.org/browse/gimp/tree/plug-ins/pygimp/plug-ins/py-slice.py

注意如何在此处调用某些过程,例如在第168行:
https://git.gnome.org/browse/gimp/tree/plug-ins/pygimp/plug-ins/py-slice.py#n168

temp_image = pdb.gimp_image_new (...)


您的代码有两个区别:


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


更改插件以做到这一点,您将获得进一步的步骤。

关于python - Python_fu插件不会在gimp中加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40419341/

10-12 05:19