/** * 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); }
/** * Opens an image and applies to filters in the given preset. * @param string $path the image path. * @param ImagePreset $preset the preset name. * @return ImageInterface the image. */ public function openImageWithPreset($path, $preset) { return $preset->applyFilters($this->openImage($path)); }