public function transform(EventInterface $event)
{
$image = $event->getArgument('image');
$pois = $this->getPoisFromMetadata($event, $image);
if (empty($pois) || !is_array($pois)) {
return;
}
$params = $event->getArgument('params');
$color = !empty($params['color']) ? $this->formatColor($params['color']) : $this->color;
$borderSize = isset($params['borderSize']) ? (int) $params['borderSize'] : $this->borderSize;
$pointSize = isset($params['pointSize']) ? (int) $params['pointSize'] : $this->pointSize;
$imageWidth = $image->getWidth();
$imageHeight = $image->getHeight();
try {
foreach ($pois as $poi) {
if (isset($poi['width']) && isset($poi['height'])) {
$this->drawPoiRectangle($poi, $color, $borderSize - 1, $imageWidth, $imageHeight);
} else {
if (isset($poi['cx']) && isset($poi['cy'])) {
$this->drawPoiCircle($poi, $color, $borderSize, $pointSize);
} else {
throw new TransformationException('Point of interest had neither `width` and `height` nor `cx` and `cy`');
}
}
}
$image->hasBeenTransformed(true);
} catch (ImagickException $e) {
throw new TransformationException($e->getMessage(), 400, $e);
}
}