| Welcome, Guest |
You have to register before you can post on our site.
|
| Latest Threads |
new plugin colour grading...
Forum: Extending the GIMP
Last Post: rich2005
Today, 08:29 AM
» Replies: 5
» Views: 625
|
ExifToolGUI and ExifTool ...
Forum: Other graphics software
Last Post: denzjos
Yesterday, 09:07 AM
» Replies: 14
» Views: 17,047
|
Langage français de l'int...
Forum: OSX
Last Post: rich2005
05-06-2026, 07:28 PM
» Replies: 1
» Views: 520
|
Locally Installed Help is...
Forum: General questions
Last Post: rich2005
05-06-2026, 10:10 AM
» Replies: 3
» Views: 701
|
scheme : error in vector
Forum: Extending the GIMP
Last Post: geka
05-06-2026, 05:40 AM
» Replies: 2
» Views: 321
|
Can a plugin be made to s...
Forum: Other graphics software
Last Post: firefox
05-06-2026, 02:23 AM
» Replies: 0
» Views: 116
|
Why does this.......
Forum: Watercooler
Last Post: CmykStudent_
05-05-2026, 08:41 PM
» Replies: 2
» Views: 670
|
How to change text inside...
Forum: General questions
Last Post: denzjos
05-05-2026, 06:39 PM
» Replies: 5
» Views: 833
|
logo for website profile ...
Forum: General questions
Last Post: tbint62
05-05-2026, 05:48 PM
» Replies: 6
» Views: 858
|
Requesting testers for CM...
Forum: General questions
Last Post: rich2005
05-05-2026, 12:28 PM
» Replies: 8
» Views: 895
|
|
|
| Issues trying to Compose an image with masked channels |
|
Posted by: pronay - 05-10-2023, 10:34 PM - Forum: Scripting questions
- Replies (5)
|
 |
Hello,
This is my first time trying to write a Python script in GIMP so I am still learning my way around this stuff.
I am trying to implement a script by which I can perform the following steps:
1. Decompose an Image into RGBA channels (Colors->Components->Decompose->Color Model: RGBA)
2. Recompose an Image using R,G channels with B and A using Mask Value of 255 (Colors->Components->Compose->Color Model: RGBA, B and A use 255 mask value)
To do this in Python, I am attempting the following steps:
Code:
decomposed = pdb.plug_in_decompose(img, drawable, "RGBA", 0)
gimp.message("Performed Decompose")
# Grab the name of the original image
fileNameWithExt = pdb.gimp_item_get_name(draw)
fileNameNoExt = fileNameWithExt.split('.')
# Create the layers
gimp.message("Creating new Layers")
gimp.message("Setting up Red Layer")
layerR = pdb.gimp_layer_new_from_drawable(pdb.gimp_image_get_active_layer(decomposed[0]), decomposed[0])
layerName = fileNameNoExt[0] + "_RGBA_Red"
pdb.gimp_item_set_name(layerR, layerName)
pdb.gimp_image_insert_layer(decomposed[0], layerR, None, 0)
gimp.message("Setting up Green Layer")
layerG = pdb.gimp_layer_new_from_drawable(pdb.gimp_image_get_active_layer(decomposed[1]), decomposed[1])
layerName = fileNameNoExt[0] + "_RGBA_Green"
pdb.gimp_item_set_name(layerG, layerName)
pdb.gimp_image_insert_layer(decomposed[1], layerG, None, 1)
gimp.message("Setting up Blue Layer")
layerB = pdb.gimp_layer_new_from_drawable(pdb.gimp_image_get_active_layer(decomposed[2]), decomposed[2])
layerName = fileNameNoExt[0] + "_RGBA_Blue"
pdb.gimp_item_set_name(layerB, layerName)
pdb.gimp_image_insert_layer(decomposed[2], layerB, None, 2)
gimp.message("Setting up Alpha Layer")
layerA = pdb.gimp_layer_new_from_drawable(pdb.gimp_image_get_active_layer(decomposed[3]), decomposed[3])
layerName = fileNameNoExt[0] + "_RGBA_Alpha"
pdb.gimp_item_set_name(layerA, layerName)
pdb.gimp_image_insert_layer(decomposed[3], layerA, None, 3)
gimp.message("Creating Layer Mask")
channelB = pdb.gimp_layer_create_mask(layerB, 1)
channelA = pdb.gimp_layer_create_mask(layerA, 1)
gimp.message("Inserting Channels to Decomposed Images")
pdb.gimp_image_insert_channel(decomposed[2], channelB, None, 0)
pdb.gimp_image_insert_channel(decomposed[3], channelA, None, 0)
# Now compose the new image into the target export image
gimp.message("Starting Compose Step for Output")
OutImage = pdb.plug_in_compose(decomposed[0], draw, decomposed[1], decomposed[2], decomposed[3], "RGBA")
gimp.message("Done with Composing Output")
However, when I run this script, I see that my output image is the exact same as the input. This means that the 255 masks are not being applied to the output composed image.
Is the approach I am using correct here? How should I be applying the 255 Mask Value to the B and A channels similar to the settings available for the Compose option in the UI?
Any advice here would be much appreciated.
|
|
|
|