GIMP Chat
http://gimpchat.com/

Python-fu gimp_drawable_levels(): "TypeError: wrong parameter type"
http://gimpchat.com/viewtopic.php?f=9&t=19694
Page 1 of 1

Author:  ipsod [ Tue Nov 16, 2021 11:36 pm ]
Post subject:  Python-fu gimp_drawable_levels(): "TypeError: wrong parameter type"

Posted this as a bug, but I'm not sure if it is a bug. I just rediscovered this forum, so hoped I could get an answer here.

Environment/Versions

GIMP version:
AppImage 2.10.22 with plugins
Linux Mint 20.2


Description of the bug
I can't find out how to use python-fu command gimp_drawable_levels. I think I've got everything correct, but the error message is unhelpful, and I don't know what to change. I suspect it's a bug, but have found so little documentation regarding this feature that I can't be sure I'm using it right.

Reproduction
Is the bug reproducible? Always.
Reproduction steps:

open python-fu console
paste this:

from gimpfu import *

input_path = '/path/to/input.png'
output_path = '/path/to/output.png'
image = pdb.gimp_file_load(input_path, input_path)

# red
pdb.gimp_drawable_levels(
image,
HISTOGRAM_RED,
0.050980392156862744,
0.95686274509803926,
False,
1.0,
0.0,
1.0,
False
)

Expected result:
no error
Actual result:
Traceback (most recent call last):
File "", line 10, in
TypeError: wrong parameter type

Author:  MareroQ [ Wed Nov 17, 2021 1:39 am ]
Post subject:  Re: Python-fu gimp_drawable_levels(): "TypeError: wrong parameter type

Hi Ipsod.
pdb.gimp_drawable_levels(drawable, channel, low_input, high_input, clamp_input, gamma, low_output, high_output, clamp_output)
You should use 'layer' not 'image'

Author:  ofnuts [ Thu Nov 18, 2021 4:59 am ]
Post subject:  Re: Python-fu gimp_drawable_levels(): "TypeError: wrong parameter type

MareroQ wrote:
Hi Ipsod.
pdb.gimp_drawable_levels(drawable, channel, low_input, high_input, clamp_input, gamma, low_output, high_output, clamp_output)
You should use 'layer' not 'image'


To be more accurate, since your loaded image has a single layer, you can obtain the drawable from your image using either "image.active_drawable" or "image.layers[0]".

This said, since it looks like you want to process files in batch, you should really look at ImageMagick, which is designed to be used in shell scripts. You possibly want to explore "-level-colors {black_color}{,}{white_color}" together with "-channel type".

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/