vCards with photos for Mac OS X

The vCard support in Mac OS X is totally broken. Address Book generates invalid vCards and can not import valid vCards. Even when it can import a vCard, is usually can’t decode a Image which might be encoded in the vCard.

If you want to generate a vCard with a Photo which can be decoded by the Apple Tools you have to ruin a valid pice of vCard data like this:

card = string_with_a_valid_vcard
filename = "some-photo.jpeg"
if File.exist? filename then
  photodata = [File.open(filename).read].pack('m').to_s
  photodata = photodata.gsub(/[ n]/, '').scan(/.{1,76}/).join("n  ")
  card.sub!('END:VCARD', "PHOTO;BASE64:n  " + photodata + "nEND:VCARD")
end
return card

gnarf

One comment on “vCards with photos for Mac OS X

  1. mdornseif
    2008-10-16 at 00:08 #

    more gnarf

    more gnarf
    You are not allowed to post to this mailing list, and your message has been automatically rejected. If you think that your messages are being rejected in error, contact the mailing list owner at vpim-talk-owner@rubyforge.org.

    From: Maximillian Dornseif
    Date: 2. September 2005 14:30:20 GMT+02:00
    To: vpim-talk@rubyforge.org
    Subject: Vpim & Adresssbook

    Did anybody so far manage to use Vpim to create a vCard including an image which will be imported by Apples Adress Book?

    Photos in vCards generated Apple’s Address Book look like this:

    PHOTO;BASE64:
    TU0AKgAA/UTY4trW4NjU3tbR29PW4Nja5Nzd597d597f6d7j7uDk7+Hk7N/k6eDt8unv9Ovt8unu
    8+zs8err8Orw9e/0+fP0+fP0+fLz+vL0+fD0+/H1+vH0+/P7//v5//v2+vft8e7+//38/vv+///9

    Photos in vCards generated by vPim look like this:

    PHOTO;encoding=b;type=image/jpeg:/9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU
    0AKgAAAAgAAAAAAAD//gAMQXBwbGVNYXJrCv/bAEMABQMEBAQDBQQEBAUFBQYHDAgHBwcHDwsLC
    QwRDxISEQ8RERMWHBcTFBoVEREYIRgaHR0fHx8TFyIkIh4kHB4fHv/bAEMBBQUFBwYHDggIDh4U

    I think the Vpim output is correct. The problem is: it is not imported into Apples Address Book with an image and that is what I need. Did anybody succeed with that so far?

    This comment was originally posted on 20050905T07:48:46

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s