I am trying to create a machine learning plug-in to help with the creation of training data. I find that GIMPs selection tools are so easy, simple and quick to use, therefore is there a way to export a selected region to a different image of the same size in the same position and then to block colour it? (this will be done procedurally, however I am not sure how to even do this through the GIMP interface) any help appreciated.

  • Could you insert temporarily a new layer to image 1, color it with the existing selection and then paste the whole colored layer to image 2? If image 2 must have a single layer only, merge down.
    – user82991
    May 17, 2021 at 16:03

2 Answers 2


If the target image exists (with the same size)

  • Create a selection in source image
  • Save to channel (Select ➤ Save to Channel)
  • Open the Channels list
  • Drag the thumbnail of the saved selection to the canvas of the target image where it will become a layer (white selection on black background)

If the target image doesn't exist yet

  • Create a selection in the source image
  • Save to channel (Select ➤ Save to Channel)
  • Open the Channels list
  • Click the saved selection channel (this makes it the active "drawable"(*))
  • Select ➤ All (Ctrl-A)
  • Edit ➤ Copy (Ctrl-C)
  • Edit ➤ Paste as ➤ new image (Ctrl-Shift-V). This creates a grayscale image.

Note: there is no one-to-one mapping between UI operations and the API, but the API can be simpler and you can likely duplicate the selection mask to a "drawable" in the other image, but this matter is better handled on StackOverflow.

(*) a "drawable" is an object on which you can alter pixels: layer, layer mask, or channel.

  1. Make a selection of something
  2. Edit > Copy
  3. Image > Duplicate
  4. Click on the tab for the new document
  5. Delete the existing image layer in the layers panel
  6. Edit > Paste in Place
  7. Select > None
  8. Choose a new foreground colour
  9. Engage the alpha lock (in the layers panel)
  10. Edit > Fill with FG colour

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.