[Vobject] Unable to add photo to vcard (Address Book OS X 10.6.4)
Markus Eberle
markus.eberle at tngtech.com
Thu Sep 16 06:15:47 CDT 2010
Roberto,
what I am doing is:
jpg = getImageAttachment(profilePageName)
if not jpg is None:
if options.verbose:
print "Image available"
j.add('photo')
j.photo.value = jpg
j.photo.encoding_param = "BASE64"
j.photo.type_param = "JPEG"
where j = vobject.vCard()
and jpg is a BASE64 encoded image.
It worked until 10.6.3 but as you say now I just checked and it does not work anymore in 10.6.4. :-(
Sorry.
Markus
Am 16.09.2010 um 11:22 schrieb Roberto Aguilar:
> 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()
> _______________________________________________
> VObject mailing list
> VObject at lists.skyhouseconsulting.com
> http://lists.skyhouseconsulting.com/mailman/listinfo/vobject
--
Markus Eberle
TNG Technology Consulting GmbH
markus.eberle at tngtech.com
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring
Geschaeftsfuehrer: Henrik Klagges, Gerhard Mueller, Christoph Stock
Amtsgericht Muenchen, HRB 135082
More information about the VObject
mailing list