/** * Resize and rotate the image if needed. */ private function normalizePhoto() { if ($this->normalized) { return; } $this->image->fixOrientation(); if ($this->image->height() > self::MAX_SIZE || $this->image->width() > self::MAX_SIZE) { $this->image->resize(self::MAX_SIZE); } $this->normalized = true; }
/** * Get contact photo */ public function getPhoto($size = 40) { if (!isset($this->vcard->PHOTO)) { return false; } else { $image = new Image(base64_encode((string) $this->vcard->PHOTO)); $image->resize($size); return 'data:' . $image->mimeType() . ';base64,' . $image->__toString(); } }