Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a mask from a selection?
#11
(02-09-2026, 04:33 PM)ersc57 Wrote: Terminology: 
You are right, by mask I mean an image with one layer that is pure black with a selection that is pure white. This is one of the input files for IOPaint inpaint.
The selection should indeed be filled with white.

Just a few tips :


To copy a selection to another image, use

Code:
SavedSelection = Gimp.Selection.save(YourImage)


and load the selection from the chanel with:


Code:
YourImage.select_item(Gimp.ChannelOps.REPLACE, SavedSelection)

I didn't test the transfer to another image, but this should work.
To fill a selection with white:

Code:
YourLayer.edit_fill(Gimp.FillType.WHITE)

https://lazka.github.io/pgi-docs/#Gimp-3....edit_fill

The python doc: https://lazka.github.io/pgi-docs/#Gimp-3.0
Reply


Messages In This Thread
How to make a mask from a selection? - by ersc57 - 02-07-2026, 08:54 AM
RE: How to make a mask from a selection? - by Scallact - 02-10-2026, 07:45 PM

Forum Jump: