function changeImage(&$im, $data) { $image = new Image(); foreach ($data as $action => $val) { switch ($action) { case 'rotate': $image->rotate($im, $val); break; case 'size': $image->resize($im, $val); break; case 'filter': $image->filter($im, $val); break; } } }
public function filterImage(Image $image, $name, $configuratorCallable = null) { $filterStrategyClassName = $this->getFilterStrategyClassnameByFilterName($name); $filterStrategy = new $filterStrategyClassName(); if (!$filterStrategy instanceof \Sokil\Image\AbstractFilterStrategy) { throw new \Exception('Filter strategy must extend AbstractFilterStrategy'); } // configure strategy if ($configuratorCallable) { call_user_func($configuratorCallable, $filterStrategy); } $image->filter($filterStrategy); return $this; }