Switch to full style
Ask all general Gimp related questions here
Post a reply

Automating Layer mask application

Mon Jul 06, 2020 3:05 pm

GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: New User



I have a lot of pairs of images with (1) color image named with the form "img-####.png" and (1) layer mask named with the form "img-####.png". The layer masks are usually but not always adjacent in number to the color images, not sure if that helps.

I have 0 experience with writing macros, installing macros, or running macros, so I will need some help with that if you're willing.

What I need is one or two macros that do the following:

Layer mask image:

Select All
Copy
Close image


Color image:

Add layer mask
Paste layer mask
Overwrite image
Close image


Can someone help me with this?

Re: Automating Layer mask application

Mon Jul 06, 2020 4:12 pm

This would be faster to do with a video editor, unless some kind hearted coder is willing to write a script for that. Basically using one image-sequence as a mask for another image-sequence.

Re: Automating Layer mask application

Tue Jul 07, 2020 3:07 am

KrytenKoro wrote:GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: New User



I have a lot of pairs of images with (1) color image named with the form "img-####.png" and (1) layer mask named with the form "img-####.png". The layer masks are usually but not always adjacent in number to the color images, not sure if that helps.

I have 0 experience with writing macros, installing macros, or running macros, so I will need some help with that if you're willing.

What I need is one or two macros that do the following:

Layer mask image:

Select All
Copy
Close image


Color image:

Add layer mask
Paste layer mask
Overwrite image
Close image


Can someone help me with this?


Somewhat simpler to script:

* Load base layer (file-load)
* Load mask image as layer (file-load-layer)
* Copy any color channel to a plain channel (channel-new-from-component)
* Discard mask layer
* Create mask on layer (later-create-mask(ADD-MASK-CHANNEL)
* Save image

Re: Automating Layer mask application

Wed Jul 08, 2020 7:22 am

ofnuts wrote:
KrytenKoro wrote:GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: New User



I have a lot of pairs of images with (1) color image named with the form "img-####.png" and (1) layer mask named with the form "img-####.png". The layer masks are usually but not always adjacent in number to the color images, not sure if that helps.

I have 0 experience with writing macros, installing macros, or running macros, so I will need some help with that if you're willing.

What I need is one or two macros that do the following:

Layer mask image:

Select All
Copy
Close image


Color image:

Add layer mask
Paste layer mask
Overwrite image
Close image


Can someone help me with this?


Somewhat simpler to script:

* Load base layer (file-load)
* Load mask image as layer (file-load-layer)
* Copy any color channel to a plain channel (channel-new-from-component)
* Discard mask layer
* Create mask on layer (later-create-mask(ADD-MASK-CHANNEL)
* Save image

How would I do that?

Re: Automating Layer mask application

Wed Jul 08, 2020 12:21 pm

This is also an option:
https://stackoverflow.com/questions/564 ... th-imagema

Just tried it, works perfectly.
Post a reply