How do I export contact photos from iCloud?

Solution 1:

When exporting vCard from iCloud Web app, the image data is not included in the card. Contact profile picture in such cases can be extracted using the included Web Developer Tools in your Web browser. The procedure is almost similar for all modern Web browsers, I'll use Safari as an example here.

Developer Tools are not enabled by default in Safari. To enable them open Safari preferences by going to Menu bar → Safari → Preferences.. or use the keyboard shortcut Command + ,. Now go to Advanced tab and check Show Develop menu in menu bar.

enter image description here

Now open Contacts section in iCloud Web app and select the desired contact. Once you have selected the contact, right click on the profile picture and select Inspect Element from the context menu. This is generally the last item in the menu.

enter image description here

Clicking on the Inspect Element item will open the Web Inspector, a tool generally used for Web design and development.

enter image description here

As you can see, the Web inspector has opened with a node pre-selected (basically an HTML image tag) corresponding to the profile picture selected. Within the tag, you'll be able to see an item similar to:

href="https://p12-contacts.icloud.com:..."

which is a hyperlink. Simply click on the link. It will display the original image assigned to the contact under the Resources tab in Web Inspector.

enter image description here

Voila! you have the contact profile picture. Simply drag the image to Finder to save it.

Solution 2:

There's a manual approach you can use to export contact image. Export the vCard normally as a .vcf file.

Now the vCard file contains the profile picture data encoded in base 64 format. Open the .vcf file in a ASCII text editor. Remove all the fields except the one starting with:

PHOTO;ENCODING=b;TYPE=JPEG:

Now, also remove the above string. You'll be left with just the base64 encoded string. Save this trimmed file. Now open Terminal and run the following command:

base64 -D -i contact.vcf -o Contact.jpeg

Here, contact.vcf is the trimmed contact card file and Contact.jpeg is the name for the desired image file.


Here's a sample vCard to illustrate the example. I have trimmed the sensitive contact information and truncated the base64 encoded image data to cut it short. Here's the original vCard data as seen in an ASCII text editor:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//iOS 12.2//EN
N:Neema;Nimesh;;;
FN:Nimesh Neema
NICKNAME:Monu
EMAIL;type=INTERNET;type=HOME;type=pref:[email protected]
EMAIL;type=INTERNET;type=HOME:[email protected]
TEL;type=CELL;type=VOICE;type=pref:+91 99999 99999
TEL;type=CELL;type=VOICE:+919999999999
TEL;type=CELL;type=VOICE:+91 99999 99999
item1.ADR;type=HOME;type=pref:;;xxx\, xxxxxxxx xxxxxxxxx\, 99/9\, xxxxxxxx;
 xxxxxx;xxxxxx xxxxxxx;000000;India
item2.URL;type=pref:http://xxxxxxxxxxx.com/
item2.X-ABLabel:_$!<HomePage>!$_
BDAY;value=date:1986-08-20
item3.IMPP;X-SERVICE-TYPE=Skype;type=pref:skype:xxxxxx.xxxxx
item3.X-ABLabel:Skype
PHOTO;ENCODING=b;TYPE=JPEG:TU0AKgAHNwSus8mus8mus8mssceus8mvtMqus8mtssisscetssivtMqts8
 mvtcuvtcuvtcuwtsyxt82yuM6xt82xt82xt82wtsywtsywtsywtsywtsyxt82vtMqxtsywtsyv
 ...
X-ABUID:A73CE32D-5308-4DBB-BAA0-DB16C1EBE31A
END:VCARD

After removing all the lines except the image data, the truncated image content looks like this:

PHOTO;ENCODING=b;TYPE=JPEG:TU0AKgAHNwSus8mus8mus8mssceus8mvtMqus8mtssisscetssivtMqts8
 mvtcuvtcuvtcuwtsyxt82yuM6xt82xt82xt82wtsywtsywtsywtsywtsyxt82vtMqxtsywtsyv
 ...

After removing the header, the final base64 string (truncated) looks like this:

TU0AKgAHNwSus8mus8mus8mssceus8mvtMqus8mtssisscetssivtMqts8
 mvtcuvtcuvtcuwtsyxt82yuM6xt82xt82xt82wtsywtsywtsywtsywtsyxt82vtMqxtsywtsyv
 ...

which needs to be saved and fed to the base64 command.

Solution 3:

Short answer:

  • it's not possible at present time to export vcard via Apple icloud procedure "Export Vcard".

In addition:

  • I've investigated the Vcard standard and the property PHOTO is supported in Vcard standard since v2.0 and also v3.0.

  • The vcf export in iCloud contacts doesn't include the PHOTO property.

  • I've contacted Apple that blindly states Vcard v3.0 is adopted.