1

How can I add a plain black line in an image in Gimp in specific pixel coordinates for example between (10,15)->(300,116)?

1

Open the Python console in filters->python->console - get a reference to your image, typing

img = gimp.image_list()[0]

and press enter. Hit the browse button at the botton of the dialog and select gimp- paintbrush-default and hit apply - it will paste a template for calling that function in the Python console - something like this:

>>> pdb.gimp_paintbrush_default(drawable, num_strokes, strokes)

Go back with the arrow keys and edit it so that it reads:

>>> pdb.gimp_paintbrush_default(img.layers[0], 4, [10,15,300,116 ])

And press enter. The img.layers[0] parameter is a reference to the layer - "0" is the top most layer in the image, 1, the second from top to bottom, and so on. (Likewise, in the previous command img = gimp.image_list()[0] retrieves a reference to the last image open in GIMP, and changing the number in square bracktes selects other images).

After the first stroke, you can simply hit up arrow, and get the command back, where you can fill in new coordinates for the line. Also, of course, you can explore the procedures available in the "Browse" button, and use any of them you like.

As few people do this, I'v just noticed a bug: in GIMP 2.8, it ignores the brush size set in the tool options. So you will have to create a brush of the size you want and set it before doing the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.