07-26-2022, 08:14 PM
Code:
from gimpfu import *
def python_c_c_r(image,layer):
pdb.gimp_image_undo_group_start(image)
pdb.gimp_context_push()
width = image.width
height = image.height
type = RGB_IMAGE
opacity = 100
mode = NORMAL_MODE
layerClean = pdb.gimp_layer_new_from_drawable(layer, image) # layer to be cleaned of alpha channel
pdb.gimp_image_insert_layer(image, layerClean, None, 0) # insert layer
pdb.gimp_image_set_component_visible(image, CHANNEL_ALPHA, FALSE) # make alpha channel non-visible
pdb.gimp_layer_flatten(layer) # remove alpha channel
pdb.gimp_image_remove_layer(image, layerClean)
pdb.gimp_context_pop()
pdb.gimp_image_undo_group_end(image)
pdb.gimp_displays_flush()
register(
"python_fu_c_c_r",
"c_c_r",
"c_c_r",
"David Marsden",
"David Marsden",
"July 2022",
"<Image>/Python-Fu/c_c_r...", #Menu path
"RGB*, GRAY*, INDEXED*",
[],
[],
python_c_c_r)
main()
Here is the total code. The same as you have seen already, apart from the parameters of the original image.
The subsequent code would create a new layer, pixelated to the maximum dimensions of the image, colour inverted and changed to overlay mode.