【问题标题】:gimp edit blend in python script produces different blend than the blend toolpython脚本中的gimp编辑混合产生与混合工具不同的混合
【发布时间】:2014-04-15 20:43:36
【问题描述】:

我正在尝试编写一个脚本,在 ubuntu 13.10 上使用 gimp 2.8 重新调整大小、移动和混合两个图像。

我在这里上传了 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

知道我做错了什么吗? 非常感谢

【问题讨论】:

标签: python gimp python-fu


【解决方案1】:

您的错误几乎在您自己的代码中 - 您正在调用混合函数传递 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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-25
    • 1970-01-01
    相关资源
    最近更新 更多