我正在编写一个插件脚本,它将打开一个文件,按颜色选择,将选择更改为新颜色,将图像另存为新文件
我不知道如何把颜色改成新的颜色。有人能提供指导吗
这就是我到目前为止所做的:
# open input file
theImage = pdb.gimp_file_load(in_filename, in_filename)
# get the active layer
drawable = pdb.gimp_image_active_drawable(theImage)
# select everything in the image with the color that is to be replaced
pdb.gimp_image_select_color(theImage, CHANNEL_OP_REPLACE, drawable, colorToReplace)
# need to do something to change the color from colorToReplace to the newColor
# but I have no idea how to change the color.
# merge the layers to maintain transparency
layer = pdb.gimp_image_merge_visible_layers(theImage, CLIP_TO_IMAGE)
# save the file to a new filename
pdb.gimp_file_save(theImage, layer, out_filename, out_filename)
您只需填写所选内容:
这将使用当前前景/背景色填充选择(取决于填充类型)。如果需要在插件中设置此颜色:
请注意,这回答了您的技术问题,但很可能这不是您想要做的(像素化边缘、剩余光晕等)。好的方法通常是用透明(在
Color Erase
模式下绘制)替换初始颜色,然后在Behind
模式下用新颜色填充孔。例如,要将FG颜色替换为BG颜色,请执行以下操作:如果不想更改图像中的其他混合颜色,请保留颜色选择,在应用两个绘制操作之前将其增长一个像素。增加选择使上述操作应用于边缘上的像素,这一点非常重要
相关问题 更多 >
编程相关推荐