2014-04-14 171 views
0

我想寫一個腳本,重新大小,移動和混合兩個圖像在一個使用gimp 2.8在Ubuntu 13.10。gimp編輯混合python腳本產生不同的混合比混合工具

我上傳了2倍所需的圖像,結果在這裏: http://imgur.com/a/bjgIA

我設法讓所有的運行,但有一點失敗。混合命令。我將問題簡化爲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

任何想法,我做錯了什麼? 非常感謝

+0

什麼是您收到的不良結果? – CodeCamper

+0

@CodeCamper http://i.imgur.com/wLzcq0a.jpg它也在上面提到的結果專輯中 – mbernasocchi

回答

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) 
        ^^^^^^^^ 

相反,做同樣的呼叫通過掩碼作爲可繪製參數(您已將其置於「掩碼」變量中):

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) 
+0

非常感謝,傻傻的新手錯誤:) – mbernasocchi