/** * Creates a new image by filtering an existing image. * @param integer $id the model id. * @param string $format the image format. * @throws CException if a required parameters is missing. */ public function actionFilter($id, $format) { if (!isset($_GET['config'])) { throw new CException('You have to provide a "config" parameter.'); } if (($model = $this->getManager()->loadModel($id, 'file')) === null) { throw new CException(sprintf('Failed to locate image model with id "%d".', $id)); } $image = $model->openImage(); $preset = ImagePreset::create(array('filters' => $_GET['config'])); $image = $preset->applyFilters($image); $image->show($format); }
/** * Creates an image preset from the given configuration. * @param array $config the configuration. * @return ImagePreset the object. */ public function createPreset($config) { return ImagePreset::create($config); }