0

ubuntu 13.10でgimp 2.8を使用して、2つの画像のサイズを変更、移動、およびブレンドするスクリプトを作成しようとしています。

必要な 2 つの画像と結果をここにアップロードしました: http://imgur.com/a/bjgIA

なんとかすべて実行できましたが、1点失敗しました。ブレンドコマンド。問題を pdb.gimp_edit_blend コマンドに減らしました。これは、レイヤーマスクを透明な背景とブレンドする代わりに、不透明なグラデーションを作成します。

image = gimp.image_list()[0]  #image is 237x300 png like above
pdb.gimp_image_resize(image, 300, 300, -100, 0)
fg_layer = pdb.gimp_image_get_active_layer(image)
mask = pdb.gimp_layer_create_mask(fg_layer,ADD_WHITE_MASK)
pdb.gimp_image_add_layer_mask(image, fg_layer, mask)

# from here it goes wrong, if I skip this step than I can get the correct result
# using the gimp blent tool from the gui using the same settings as here
pdb.gimp_edit_blend(fg_layer, FG_BG_RGB_MODE, NORMAL_MODE, GRADIENT_LINEAR, 100, 0, 0, True, False, 0, 0, True, 0, 150, 150, 150)

コード全体はこちら: http://pastie.org/9079343

私が間違っていることを知っていますか?どうもありがとう

4

1 に答える 1

0

あなたのエラーはほとんどあなた自身のコードにあります - マスクの代わりに fg_layer を最初のパラメータとして渡してブレンディング関数を呼び出しています:

pdb.gimp_edit_blend(fg_layer, FG_BG_RGB_MODE, NORMAL_MODE, GRADIENT_LINEAR, 100, 0, 0, True, False, 0, 0, True, 0, 150, 150, 150)
                    ^^^^^^^^

代わりに、drawable パラメーターとしてマスクを渡して同じ呼び出しを行います (既に "mask" 変数に含まれています)。

pdb.gimp_edit_blend(mask, FG_BG_RGB_MODE, NORMAL_MODE, GRADIENT_LINEAR, 100, 0, 0, True, False, 0, 0, True, 0, 150, 150, 150)
于 2014-04-15T12:43:36.593 に答える