[Vobject] Unable to add photo to vcard (Address Book OS X 10.6.4)

Roberto Aguilar roberto.c.aguilar at gmail.com
Fri Sep 17 03:34:56 CDT 2010


Jeffrey & Matthew,

Thanks for the response.  I swear I tried a very similar snippet as the one below prior to emailing, but whatever was broken is now fixed with your magic snippet.

Thanks!
-Roberto.

On Sep 16, 2010, at 7:46 AM, Jeffrey Harris wrote:

> 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" 
> 
> _______________________________________________
> VObject mailing list
> VObject at lists.skyhouseconsulting.com
> http://lists.skyhouseconsulting.com/mailman/listinfo/vobject



More information about the VObject mailing list