Creating text on images

Discussion in 'Python' started by morphex, Jan 13, 2005.

  1. morphex

    morphex Guest

    Hi all,

    I'm trying to create a script that will superimpose text on an image.
    I didn't find any great examples out there on how this can be done (I
    presume using PIL is necessary), do you know of any examples?
    Thanks,

    Morten
     
    morphex, Jan 13, 2005
    #1
    1. Advertising

  2. morphex wrote:
    > Hi all,
    >
    > I'm trying to create a script that will superimpose text on an image.
    > I didn't find any great examples out there on how this can be done (I
    > presume using PIL is necessary), do you know of any examples?
    > Thanks,
    >
    > Morten
    >


    Hi,

    something like this?

    ###
    from PIL import Image, ImageFont, ImageDraw
    import sys

    im = Image.open(YOUR_IMAGE_HERE)
    idraw = ImageDraw.Draw(im)
    idraw.text((1,1),"Hello", fill=128)
    im.save(YOUR_NEW_IMAGE_HERE, IMAGE_TYPE)
    ###

    HtH, Roland
     
    Roland Heiber, Jan 13, 2005
    #2
    1. Advertising

  3. morphex

    morphex Guest

    Yes, something like that. I was a bit confused when it came to using
    truetype fonts, but that was straightforward enough (just pass font
    objects to the text method). :)
     
    morphex, Jan 13, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    901
    Eliyahu Goldin
    Jan 4, 2005
  2. Luis Esteban Valencia Muñoz
    Replies:
    0
    Views:
    773
    Luis Esteban Valencia Muñoz
    Jun 3, 2005
  3. wardemon

    Cache Images vs Static Images

    wardemon, Jun 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    666
    bruce barker
    Jun 14, 2007
  4. Keith Hughitt
    Replies:
    6
    Views:
    1,073
  5. Adrienne Boswell
    Replies:
    1
    Views:
    511
    dorayme
    Aug 4, 2009
Loading...

Share This Page