×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    2

    Red face How to add a text to an image?

    Hi all,
    I want to try some basic processing on an image stored in a mobile device using python. I just want to have some help to get started, adding a text for example.

    Thanks in advance for ur help,
    A very newbie pys60 developer!

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: How to add a text to an image?

    Hi sos_mobile_dev and welcome to the Python Discussion Board.

    Code:
    from graphics import *
    
    bg=Image.new((240,240))
    bg.text((30,30), u"text", font="title")
    bg.save("c:\\a.jpg", quality=100)
    Now, the explanation:

    First, I created a new blank image of 240x240 pixels (instead, you could use a photo or something else, it make no difference).
    Then I added the word "text" to the coordinates 30 and 30 of the image.
    Lastly, I saved it to the path "c:\" with the filename "a.jpg", at top quality (quality can range from 0 to 100).

    Example for a photo:
    Code:
    from graphics import *
    
    photo=Image.open("c:\\myphoto.jpg")
    photo.text((45,30), u"Text goes here", font="normal")
    photo.save("c:\\mynewphoto.jpg")
    For a list of fonts, see this article

    Hope that helps
    Last edited by bogdan.galiceanu; 2008-04-28 at 18:29.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    2

    Re: How to add a text to an image?

    it s very helpful!
    Thanks

  4. #4
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: How to add a text to an image?

    Hi Bogdan,

    I added it to the Wiki for further reference.
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

Similar Threads

  1. How to add text message to image
    By susheel1 in forum Symbian
    Replies: 1
    Last Post: 2007-06-06, 11:47
  2. How to add text message to Image
    By susheel1 in forum General Messaging
    Replies: 2
    Last Post: 2007-06-06, 07:00
  3. How to post image along with text on a single request
    By Basu in forum Mobile Java Networking & Messaging & Security
    Replies: 9
    Last Post: 2006-12-15, 23:49
  4. saving jpeg image on grid list
    By flicker82 in forum Symbian
    Replies: 0
    Last Post: 2005-01-21, 04:22
  5. Replies: 0
    Last Post: 2004-11-24, 18:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×