1

python_fu を使用して gimp プラグインを作成しようとしています。同じサイズのレイヤーをたくさん取り、それらを垂直に並べたいと思います。これは、各ページが 1 つのレイヤーを占める PDF ファイルを開くために使用され、プラグインはそれらを 1 行に配置します。プラグインを実行しても、メニューに何も表示されません。その上にアスタリスクが付いている行をコメントアウトすると、プラグインがメニューに読み込まれます。

%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()
4

2 に答える 2

2

https://git.gnome.org/browse/gimp/tree/plug-ins/pygimp/plug-ins/py-slice.pyなど、いくつかの既存の Python ベースのプラグインをご覧ください。

たとえば 168 行目で、いくつかのプロシージャがどのように呼び出されるかに注意してください: https://git.gnome.org/browse/gimp/tree/plug-ins/pygimp/plug-ins/py-slice.py#n168

temp_image = pdb.gimp_image_new (...)

コードには 2 つの違いがあります。

  1. pdb プレフィックス
  2. ハイフン/マイナスの代わりにアンダースコア

プラグインをこのように変更すると、さらにいくつかの手順を実行できます。

于 2016-11-04T12:23:53.310 に答える