[Vobject] Unable to add photo to vcard (Address Book OS X 10.6.4)
Roberto Aguilar
bertosmailbox at gmail.com
Thu Sep 16 04:22:11 CDT 2010
Hello,
I'm trying to use the vobject python module to build a vcard with an embedded photo. Using the code below, the photo does not show up. I have tried setting vcard.wacky_apple_photo_serialize to True or False, but that does not help. I've also tried different variations of the encoding_param, as well as adding/removing the photo type_param.
Additionally, taking a look at vcards with embedded photos, I manually removed the "encoding=" from the photo line, but still no dice.
Any help is greatly appreciated.
Thanks,
-Roberto.
#!/usr/bin/env python
import base64
import sys
import vobject
from vobject import vcard
vcard.wacky_apple_photo_serialize = False
card = vobject.vCard()
card.add('n')
card.n.value = vobject.vcard.Name(family='smith', given='john')
card.add('fn')
card.fn.value = 'John Smith'
filename = sys.argv[1]
f = open(filename)
data = f.read()
f.close()
b64 = base64.encodestring(data)
card.add('photo')
card.photo.value = b64
#card.photo.type_param = 'JPEG'
card.photo.encoding_param = 'b'
outfile = sys.argv[2]
f = open(outfile, 'wb')
f.write(card.serialize())
f.close()
More information about the VObject
mailing list