Gimp python-fu脚本选择具有给定颜色的所有内容并将其更改为其他颜色

I am writing a plugin script that will open a file, select by color, change the selection to a new color, save image as a new file.

I don't know how to change the color to a new color. Can someone provide guidance?

This is what I have so far:

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