1

I want to create a white background in my gimpfu plugin. I found the option to fill a drawable by using pdb.gimp_drawable_fill(drawable, 2) but there I have to select a drawable and the drawable fills not automatically the whole image.

Is there an option in gimpfu to fill the whole image with one color?

Joko
  • 13
  • 2

1 Answers1

2

In Gimp you have to paint/fill on a layer, so you add a layer that you fill:

# Create layer
background=gimp.Layer(image,'Background',image.width,image.height,RGB_IMAGE,100.,LAYER_MODE_NORMAL)
# Fill with white (this doesn't consider the selection, the whole layer is always painted)
background.fill(FILL_WHITE)
# Add at bottom of layer stack
image.add_layer(background,len(image.layers))

if you want something else than white, then replace background.fill(FILL_WHITE) with

import gimpcolor

gimp.set_background(gimpcolor.RGB(100,120,140))
background.fill(FILL_BACKGROUND)
xenoid
  • 8,396
  • 3
  • 23
  • 49