0

I have a function that takes an image and puts it in my contact vcf file as the profile photo. The problem is that the image is being shown rotated 90 degrees in my vcf file. I was suggested to clear all EXIF data but don`t really know how to implement this in my function down here.

def b64_image(filename):
        response = urllib.request.urlopen("static/img/" + filename)
        b64 = base64.b64encode(response.read())
        return b64.decode('utf-8')

vcf_file_path = 'static/Contacto.vcf'
with open(vcf_file_path , 'w') as file_vcard:
   vcard = vobject.vCard()
   o = vcard.add('fn')
   o.value = rowes.name
   o = vcard.add('PHOTO;ENCODING=b;TYPE=image/jpeg')
   o.type_param = 'PHOTO'
   o.value = b64_image(rowr.img_url)

I've tried solutions in already asked questions but dont work in my case. Thanks in advance.

  • One option would be [using PIL to strip exif](https://stackoverflow.com/a/23249933/2052575). Although [this thread](https://stackoverflow.com/questions/43966248/pil-images-not-rotating) may give some clues on how to handle that, also with PIL. – v25 Jun 04 '20 at 19:07
  • It sounds like you clear all exif data except orientation, or clear it all and then restore orientation. https://stackoverflow.com/questions/43253889/imagemagick-convert-how-to-tell-if-images-need-to-be-rotated might help. – Dave W. Smith Jun 04 '20 at 21:15

0 Answers0