Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

How to use gimp_image_remove_channel in Python-Fu?

Sun Sep 07, 2014 12:23 pm

Details here. What text would complete the first line here in order to define the alpha channel? image is already defined.

Code:
channel =
gimp.pdb.gimp_image_remove_channel(image,channel)

Re: How to use gimp_image_remove_channel in Python-Fu?

Sun Sep 07, 2014 2:29 pm

You can't remove the alpha channel of the whole image that way. You have to use either:
Code:
image.flatten()
# or
pdb.gimp_image_flatten(image)

Re: How to use gimp_image_remove_channel in Python-Fu?

Sun Sep 07, 2014 3:43 pm

What function is called by the menu item Layer > Transparency > Remove Alpha Channel?

Re: How to use gimp_image_remove_channel in Python-Fu?

Sun Sep 07, 2014 3:54 pm

Likely none, if it's an internal function. Not all menus are plugins/scripts.

This said removing the alpha channel of a layer has little purpose...

Re: How to use gimp_image_remove_channel in Python-Fu?

Mon Sep 08, 2014 8:52 am

It calls "gimp_layer_flatten", which is indeed the procedure
to remove alpha channel from layer.

Re: How to use gimp_image_remove_channel in Python-Fu?

Wed Oct 01, 2014 1:15 pm

Onkel Hatti wrote:It calls "gimp_layer_flatten"
Is this a guess, or did you check? Remove Alpha Channel works quickly and reliably with very large images. Flatten on the other hand takes a long time and frequently causes GIMP to crash with very large images.

If Remove Alpha Channel doesn't call gimp_image_remove_channel, what is gimp_image_remove_channel for and how do you use it?

Re: How to use gimp_image_remove_channel in Python-Fu?

Wed Oct 01, 2014 2:46 pm

gimp_image_remove_channel() removes the channels you can add to the image (saved selections, etc...).

Re: How to use gimp_image_remove_channel in Python-Fu?

Wed Oct 01, 2014 3:47 pm

Lumo wrote:
Onkel Hatti wrote:It calls "gimp_layer_flatten"
Is this a guess, or did you check?

Why the doubt?

Lumo wrote:Remove Alpha Channel works quickly and reliably with very large images. Flatten on the other hand takes a long time and frequently causes GIMP to crash with very large images.

Flattening an image will definitely take longer than flattening a layer. There is much more happening when flattening an image.

Flattening an image consists of initiating an UNDO group, producing a new temporary layer to store the result, producing another new temporary layer filled with the background color, merging the layers taking into account blend modes, opacities, visibilities, offsets, boundaries, and any layermasks (as well as copying parasites and tattoos), positioning the new layer in the layerstack, deleting all of the original layers as well as the background layer, flattening the new layer, and ending the UNDO group.

Even if the image comprises only a single layer, doing all of those steps will take longer than the single step of flattening the original layer, which is a simple pixel-by-pixel compositing against a single color and storing it back into the original layer (flattening a layer is one of the steps that needs to be done when flattening the image, anyway).
Post a reply