Sha256: 649be03f4e1eeb6af3c247eb05a0d77650c951233874f4f499bad8280cfcd9a2

Contents?: true

Size: 462 Bytes

Versions: 24

Compression:

Stored size: 462 Bytes

Contents

#!/usr/bin/ruby -w

require 'vpim/vcard'

vcf = open(ARGV[0] || 'data/vcf/Sam Roberts.vcf')

card = Vpim::Vcard.decode(vcf).first

card.photos.each_with_index do |photo, i|
  file = "_photo_#{i}."

  if photo.format
    file += photo.format.gsub('/', '_')
  else
    # You are your own if PHOTO doesn't include a format. AddressBook.app
    # exports TIFF, for example, but doesn't specify that.
    file += 'tiff'
  end

  open(file, 'w').write photo.to_s
end

Version data entries

24 entries across 24 versions & 11 rubygems

Version Path
vpim-0.619 samples/ex_get_vcard_photo.rb
vpim-0.695 samples/ex_get_vcard_photo.rb
vpim-0.604 samples/ex_get_vcard_photo.rb
vpim-0.602 samples/ex_get_vcard_photo.rb