Previous | Next

Create a new image

#!/usr/bin/env python

from gimpfu import *

def hello_world(initstr, font, size, color) :
    img = gimp.Image(1, 1, RGB)

    gimp.set_foreground(color)

    layer = pdb.gimp_text_fontname(img, None, 0, 0,
                                   initstr, 10, True,
                                   size, PIXELS, font)

    img.resize(layer.width, layer.height, 0, 0)

    gimp.Display(img)
The 1, 1 is a little tricky.

That's the initial image size.

I want the image to be the size of the text I'm going to create --

but I won't know what size until after I've created the text layer.