It is currently Thu Aug 06, 2026 8:22 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Using Layer Masks in Python 3.0 plugins
PostPosted: Fri Aug 08, 2025 10:44 am  (#1) 
Offline
GimpChat Member

Joined: Jun 28, 2025
Posts: 6
Hi, I am writing a smart sharpener plugin using python 3.0. I use a layer mask to define edges in the image which will be sharpened. Problem is: I can create and attach the layer mask, but I cannot apply the mask to the layer using the Gimp python library (the attach plugin doesn't exist - though it did in Gimp 2.10!). Without it the sharpener ignores the mask (and likewise for any plugin that uses a layer mask). Can anybody suggest a fix? Thanks.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Using Layer Masks in Python 3.0 plugins
PostPosted: Fri Aug 08, 2025 12:01 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2019
Posts: 282
Location: Lake Havasu City, Arizona, USA
Hi stargazy,

I sifted through LMDT code and found this where I successfully applied a mask to its layer:
if layer.get_mask():
    layer.set_apply_mask(True)
    layer.remove_mask(Gimp.MaskApplyMode.APPLY)

_________________
Charles


Top
 Post subject: Re: Using Layer Masks in Python 3.0 plugins
PostPosted: Sat Aug 09, 2025 8:24 am  (#3) 
Offline
GimpChat Member

Joined: Jun 28, 2025
Posts: 6
Hi gasMask,

Many thanks for your response. I will give your suggestion a try and report back!

Stargazy


Top
 Post subject: Re: Using Layer Masks in Python 3.0 plugins
PostPosted: Mon Aug 11, 2025 10:34 am  (#4) 
Offline
GimpChat Member

Joined: Jun 28, 2025
Posts: 6
Hi gasMask!

I have tried your suggestion and can confirm that it works as expected. Many thanks for your help - I would never have got there without your input. I had tried the layer.set_mask but didn't realize the mask had to be removed afterwards. It wasn't that way with Gimp 2.10, but I guess that's a common complaint these days!

Stargazy


Top
 Post subject: Re: Using Layer Masks in Python 3.0 plugins
PostPosted: Mon Aug 11, 2025 2:13 pm  (#5) 
Offline
GimpChat Member

Joined: Apr 11, 2024
Posts: 306
Sometimes you really have to be creative using this new API.
But we'll get used to that ....
BTW...
Just in case you have not found it yet, API References are here:
https://developer.gimp.org/resource/api/

(Difficult to find if you don't know where to click on GIMP's homepage.
Would be nice to have it in the top navigation )


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group