[Vobject] Photo embedding with VObject, python 2.7

Yanilda Peralta yanilda.peralta at gmail.com
Fri Oct 28 09:21:44 CDT 2016


Thank you so much for your time,
After trying your snippet it produces the same output that you post,
however when I open the vcard that I write to a file, the photo doesn't
show any photo I don't know why.


This is what I  try:

photo_1=open('photo.jpg','rb')
x = card.add('photo')
x.type_param = 'JPEG'
photo_1.seek(0)
x.value =  base64.encodestring(photo_1.read())

filename= 'file.vcf'

out = open(filename, 'a')
out.write(card.serialize().encode('utf-8'))
out.close()

output:

BEGIN:VCARD

VERSION:3.0
.
FN:SD

N:D;S;;;

PHOTO;TYPE=JPEG:/9j/4AAQSkZJRgABAQEAwAD.....




On Fri, Oct 28, 2016 at 6:51 AM, Adam Tauno Williams <
awilliam at opengroupware.us> wrote:

> On Fri, 2016-10-28 at 06:34 -0400, Adam Tauno Williams wrote:
> > On Thu, 2016-10-27 at 14:34 -0400, Yanilda Peralta wrote:
> > > Hi, I've tried different snippets to get the the photo embedded on
> > > the vcard object but It doesn't seem to be working in any ways.
> > It works for me with -
> >   x = card.add('photo')
> >   x.encoding_param = "b"
> >   x.type_param = 'JPEG'
> >   scratch_file.seek(0)  # contains a JPEG image
> >   x.value = scratch_file.read()
> > The above works in Python 2.6 & 2.7
>
> Produces -
>
> N:Williams;Adam;;;
> PHOTO;TYPE=JPEG;ENCODING=b:/9j/4AAQSkZJRgABAQAA.....
>
>
> --
> Adam Tauno Williams <mailto:awilliam at whitemice.org> GPG D95ED383
> OpenGroupware Developer <http://www.opengroupware.us/>
>
>
> _______________________________________________
> VObject mailing list
> VObject at lists.skyhouseconsulting.com
> http://lists.skyhouseconsulting.com/mailman/listinfo/vobject
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.skyhouseconsulting.com/pipermail/vobject/attachments/20161028/156ab78a/attachment.html>


More information about the VObject mailing list