[Vobject] Unable to add photo to vcard (Address Book OS X 10.6.4)
Jeffrey Harris
jeffrey at skyhouseconsulting.com
Thu Sep 16 09:46:04 CDT 2010
Hi Roberto,
I suspect Matthew's answer should solve your problem, unless Address Book has gotten even more finicky about reading photos (which is possible, but would be odd).
The key is that vobject's serialize handles encoding for you, if you give it an encoding parameter that it recognizes (in vcard 3.0's case, the base64 encoding parameter is "B").
Setting the global flag vcard.wacky_apple_photo_serialize to False (it defaults to True) would try to serialize vcard photo details "correctly", i.e., by folding the base64 encoded lines at 80 characters or so. This isn't done, normally, because historically AddressBook expected very specific extra whitespace if lines were folded.
Let me know if that doesn't solve the issue for you!
- Jeffrey
> I don't remember why, but this is a tricky one to get working. Here's what I do and it's worked for me:
>
> photo_fh=open(photo_filename,'rb')
> card.add('photo')
> card.photo.value = photo_fh.read()
> card.photo.encoding_param = "b"
> card.photo.type_param = "JPEG"
More information about the VObject
mailing list