vobject icon indicating copy to clipboard operation
vobject copied to clipboard

No mime parameters separately available for PHOTO property (as well as LOGO, KEY & SOUND?)

Open blacksenator opened this issue 5 years ago • 0 comments

For the handling of images that come embedded with the PHOTO property I have to evaluate the mime type (only JPEGs should be considered). I have found no way for vCards version 4.0 to access the base64 data and their parameters separately. As far as I can see, there is no possibility to do so:

[value:protected] => data:image/jpeg;base64,[base64-data]

Please adjust the using instructions or even better extend the parsing routines

+++Update+++ After a day of tries and analysis, I only came to this solution for me:

if ($vcard->VERSION == '4.0') {
    $value = explode(',', $vcard->PHOTO, 2);
    if (!preg_match("/jpeg/", $value[0])) {
       continue;
    } else {
        $vcardImage = base64_decode($value[1]);
    }
}

What is analogous to this version 3.0, which is much smarter to handle!

if ($vcard->VERSION == '3.0') {
    if ($vcard->PHOTO['TYPE'] != 'JPEG') {
        continue;
    } else {
        $vcardImage = $vcard->PHOTO;
    }
}

That can not be it, right? Is there really no better way?

blacksenator avatar Jun 05 '19 10:06 blacksenator