Previous | Next

Resize the 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)
This is the only tricky part.

When we created the image, we didn't know how big the text would be. So we create the image as 1x1 pixel, then resize it once we know the size of the text layer.