Issues porting a curve script to GIMP 3 (original) (raw)

Hello everyone, I’ve been spending a few hours porting an old trusted script-fu script to the python API in GIMP 3.0. This has proven to be an incredibly frustrating process due to the complete lack of documentation, I’ve been mostly hopping from random forum post to random forum post, piecing together how it’s supposed to work through trial and error.

I have managed to port mostly everything but I’m stuck on how to apply a curve to the image:

This is what I had in my old script:

(gimp-curves-spline drawable HISTOGRAM-VALUE 8 #(0 0 82 0 223 255 255 255))

In my new python script I do:

curves_proc = pdb.lookup_procedure("gimp-drawable-curves-spline")
curves_conf = curves_proc.create_config();

curve_points = [0, 0, 82, 0, 223, 255, 255, 255]
curves_conf.set_property("drawable", drawables[0])
curves_conf.set_property("channel", Gimp.HistogramChannel.VALUE)
curves_conf.set_property("points", curve_points)

curves_proc.run(curves_conf)

The issue is that curves_conf.set_property("points", curve_points) wants a GimpDoubleArray:

TypeError: could not convert [0, 0, 82, 0, 223, 255, 255, 255] to type 'GimpDoubleArray' when setting property 'GimpProcedureConfig-gimp-drawable-curves-spline.points'

The problem is that I have no idea how I’m supposed to instanciate a GimpDoubleArray. The closest I got was:

        curve = Gimp.Array()
        Gimp.DoubleArray.set_values(curve, curve_points, False)

Which does create an Array containing doubles, but passing that to set_property also fails the type check:

TypeError: could not convert <Gimp.Array object at 0x7ac4a706d7f0 (GimpArray at 0x5a7f0854be70)> to type 'GimpDoubleArray' when setting property 'GimpProcedureConfig-gimp-drawable-curves-spline.points'

So what’s the trick?

Thank you for your help.