Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gimp 3 Python Script - Merge Visible - No Flatten Image?
#1
Not sure if this is a problem with the documentation or if it's a bug, maybe someone here can shed some light.

I'm converting my Gimp 2 scripts to Gimp 3 and noticed that in v3 there is a new merge type listed in the docs for the description of:
gimp-image-merge-visible-layers

Under the parameters it lists:

Quote:The type of merge { EXPAND-AS-NECESSARY (0), CLIP-TO-IMAGE (1), CLIP-TO-BOTTOM-LAYER (2), FLATTEN-IMAGE (3) }, default EXPAND-AS-NECESSARY (0)


However calling gimp-image-merge-visible-layers , like so:


Code:
layer = merge_visible(img, Gimp.MergeType.FLATTEN_IMAGE)


Where merge_visible looks like this:


Code:
def merge_visible(image: Gimp.Image, merge_type: Gimp.MergeType = Gimp.MergeType.EXPAND_AS_NECESSARY)->Gimp.Layer:
    """
    Merge the visible layers of an image into a single layer.
    This procedure combines the visible layers into a single layer using the specified merge type.
    A merge type of EXPAND_AS_NECESSARY expands the final layer to encompass the areas of the visible layers.
    A merge type of CLIP_TO_IMAGE clips the final layer to the extents of the image.
    A merge type of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost layer.

    :param image: Gimp image with the layers to be merged
    :param merge_type: the type of merge:
        0 = Expand as Necessary
       1 = Clip to image
        2 = clip to bottom
        3 = Flatten Image

        default = Expand as Necessary
    :return: The merged layer
    """
    procedure = Gimp.get_pdb().lookup_procedure('gimp-image-merge-visible-layers')
    config = procedure.create_config()
    config.set_property('image', image)
    config.set_property('merge-type', merge_type)
    result = procedure.run(config)
    success = result.index(0)
    layer = result.index(1)
    return layer


However this results in an error:


Quote:GIMP-Error: Calling error for procedure 'gimp-image-merge-visible-layers':

Procedure 'gimp-image-merge-visible-layers' has been called with value 'GIMP_FLATTEN_IMAGE' for argument 'merge-type' (#2, type GimpMergeType). This value is out of range.

Thanks,
Jordan
Reply


Messages In This Thread
Gimp 3 Python Script - Merge Visible - No Flatten Image? - by silenuznowan - 03-31-2025, 05:48 PM

Forum Jump: