protected function createMask($maskPath, $width, $height) { try { // todo get this from a service $imagine = new ImagickImagine(); } catch (\RuntimeException $ex) { $imagine = new GdImagine(); } $mask = $imagine->open($maskPath); $mask->resize(new Box($width ?: 1, $height ?: 1)); return $mask; }