×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    49

    Add thumbnail image to contact

    Hello,

    is it possible to add a thumbnail image to a contact?

    The type 'thumbnail_image' cannot be created for a Contact instance - is there any other way?

    Thanks,
    Lukas

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Add thumbnail image to contact

    Quote Originally Posted by Lukas Hetzenecker View Post
    Hello,

    is it possible to add a thumbnail image to a contact?

    The type 'thumbnail_image' cannot be created for a Contact instance - is there any other way?

    Thanks,
    Lukas
    hello Lukas

    i think this is already been discussed somewhere in the forum, a extensive search will definitely help you.

    Now AFAIK there is no direct method yet tp add a thumbnail to your contacts database, if you want you can make your customized contacts with images in it, like a customized listbox with images.

    Hope you got that.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    49

    Re: Add thumbnail image to contact

    It seems like getting, updating and removing the thumbnail only works from importing and exporting vcards

    I wrote a function that takes a Contact object and and return the thumbnail image for this contact.
    There is also one which can set and delete the thumbnail:

    Code:
    class YourClass(object):
    
        def contactThumbnail(self,  contact):
            # Ugly workaround!
            # HACK: The value of type "thumbnail_image" is empty, it is only shown when we export the contact to a vCard
            image = contact.as_vcard()
            try:
                image = image.split("PHOTO;")[1].split("\r\n\r\n")[0]
                image = image.split("ENCODING=BASE64:")[1].split("\r\n\r\n")[0]
                image = image.replace("\r",  "").replace("\n",  "").replace(" ",  "")
            except:
                return
            return image
    
        def contactThumbnailAdd(self,  contact,  image="PHOTO;\r\n\r\n"):
            # Ugly workaround!
            # HACK: There seems to be new other way to update/add the contact picture
            cdb = contacts.ContactsDb()
            card = contact.as_vcard()
    
            try:
                try:
                    # Remove old picture, if there is any
                    part = card.split("\r\nPHOTO;")
                    card = part[0] + "\r\n" + part[1].split("\r\n\r\n")[1] + "\r\n"
                except IndexError:
                    #traceback.print_exc()
                    pass
                
                # TODO: Python 2.5 required
                #head,  sep,  tail = card.partition("END:VCARD\r\n")
                sep = "END:VCARD\r\n"
                head, tail = card.split(sep, 1)
                
                img = ""
                for i in range(len(image)/64):
                    img += image[i*64:(i+1)*64]
                    img += "\r\n    "      
    
                    new = head + "\r\nPHOTO;TYPE=JPEG;ENCODING=BASE64:" + "\r\n    " + img.strip() + "\r\n\r\n" + sep + tail
                else:
                    new = head + sep + tail
    
                changed_contact = cdb.import_vcards(new)[0]
                assert changed_contact.id == contact.id
            
            except Exception, e:
                #traceback.print_exc()
                return

Similar Threads

  1. How to get path of thumbnail attched to contact.
    By shrawan_gupta in forum Symbian C++
    Replies: 3
    Last Post: 2011-01-06, 14:55
  2. Signed application shows prompt if I delete and when I add tel to a contact
    By manupeco in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2009-05-23, 11:50
  3. add contact from default phonebook error
    By gopikishan in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2009-05-11, 13:08
  4. why i can not add new contact to contact database!
    By ernestliu_nk in forum Symbian C++
    Replies: 1
    Last Post: 2008-01-23, 18:39
  5. Blog - Add Image (Screen Dump)
    By Zargron in forum Mobile Web Server
    Replies: 2
    Last Post: 2008-01-08, 15:23

Posting Permissions

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