static function create_image($event, $width, $height, $photo) { $photo_width_percent = 0.4; $text_width_percent = 1 - $photo_width_percent; $photo_width = $width * $photo_width_percent; $text_width = $width * $text_width_percent - 10; $image = new Imagick(); $draw = new ImagickDraw(); $pixel = new ImagickPixel('gray'); //or transparent $image->newImage($width, $height, $pixel); $image->setImageFormat('png'); //$photo_blurred = clone $photo; //$photo_blurred->blurImage(20.0, 20.0); //$photo_blurred->modulateImage(50, 50, 100); ImageCompositor::scale_crop_composite($photo, $image, $height, $photo_width, 0, 0); //scale_crop_composite($photo_blurred, $image, $height, $width * 0.6, $photo_width, 0); $testRect = new Rect(10, 20, 30, 40); ImageCompositor::composite_paragraph($event->name, $image, new Rect($photo_width + 10, 75, $text_width, 128), False); ImageCompositor::composite_paragraph($event->description, $image, new Rect($photo_width + 10, 150, $text_width, 128), True); $contact_string = ""; if ($event->show_name or $event->show_email or $event->show_phone) { $contact_string = "Contact:"; } if ($event->show_name) { $contact_string = $contact_string . " " . $event->contact_name; } if ($event->show_phone) { $contact_string = $contact_string . " " . $event->contact_phone; } if ($event->show_email) { $contact_string = $contact_string . " " . $event->contact_email; } // if($event->show_website){ // $contact_string = $contact_string . " " . $event->contact_website; // } ImageCompositor::composite_paragraph($contact_string, $image, new Rect($photo_width + 10, $height - 10, $text_width, 50), False); //ImageCompositor::render_image($image); //exit(); return $image; }