Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Removing Alpha Channel?
#5
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.
Reply


Messages In This Thread
Removing Alpha Channel? - by david - 07-26-2022, 02:27 PM
RE: Removing Alpha Channel? - by Ofnuts - 07-26-2022, 04:11 PM
RE: Removing Alpha Channel? - by david - 07-26-2022, 06:05 PM
RE: Removing Alpha Channel? - by Ofnuts - 07-26-2022, 07:34 PM
RE: Removing Alpha Channel? - by david - 07-26-2022, 08:14 PM
RE: Removing Alpha Channel? - by PixLab - 07-27-2022, 01:58 AM
RE: Removing Alpha Channel? - by david - 07-27-2022, 07:38 AM
RE: Removing Alpha Channel? - by rich2005 - 07-27-2022, 07:51 AM
RE: Removing Alpha Channel? - by david - 07-27-2022, 11:54 AM
RE: Removing Alpha Channel? - by Ofnuts - 07-27-2022, 05:33 PM
RE: Removing Alpha Channel? - by david - 07-28-2022, 09:34 AM
RE: Removing Alpha Channel? - by Ofnuts - 07-28-2022, 12:08 PM
RE: Removing Alpha Channel? - by david - 07-28-2022, 03:56 PM

Forum Jump: