PIL text on SGI

Kevin Cazabon kcazabon at home.com
Tue Mar 21 21:56:59 EST 2000


Try the following... It just makes a new image with text on it, and returns
it.  It "should" work on all systems, provided you have a valid PIL font.

If you need PIL fonts, I have some posted at:

http://members.home.com/lenticular

If this doesn't work... well then, there's a problem.  Maybe something to do
with an SGI build of PIL.  I think Fred's out of touch for a few days, but
he'd be the one to ask about that.

###########################################
import Image, Imagefont, Imagedraw

def testFont(font, text = "@ABC123abc", show = 0):
    # figure out how large the test image will be
    im = Image.new("1", (1,1))
    font = Imagefont.load(font)
    draw = Imagedraw.Draw(im)
    draw.setfont(font)
    draw.setink(0)
    textsize = draw.textsize(text)

    textsize = (textsize[0] + 10, textsize[1] + 10)

    # create the test image
    im = Image.new("1", textsize, (1))
    draw = Imagedraw.Draw(im)
    draw.setfont(font)
    draw.setink(0)

    draw.text((5,5), text)

    # show it, or return it
    if show == 1:
        im.show()
        return 0
    else:
        return im

im = testfont(fontfilename, "Whatever text you want to see")
im.save(wherever)

########################################
"James Vincent" <jjv5 at nih.gov> wrote in message
news:38D7AAD0.5E6343A8 at nih.gov...
> Hello,
>
>
> Does anyone have success using PIL to create text in an image
> on an SGI? I am able to do everything correctly under Linux, but under
> IRIX 6.5.6
> I get no exceptions, but also no text in any image of any type. Lines,
> rectangles,
> colors all work, just not text. Any help is appreciated.
>
> Jim
>
>
> --
>
>
> James Vincent
> jjv5 at nih.gov





More information about the Python-list mailing list