/** * Adds a watermark to an existing image. * @param string $filename the image file path or path alias. * @param string $watermarkFilename the file path or path alias of the watermark image. * @throws \CException if `$start` is invalid */ public static function addWatermark($filename, $watermarkFilename) { $imagine = static::getImagine(); $transformation = new Transformation(); $transformation->add(new Watermark($imagine, $watermarkFilename)); $transformation->apply($imagine->open($filename))->save(); }
public function testFilterSorting() { $filter1 = new TestFilter(); $filter2 = new TestFilter(); $filter3 = new TestFilter(); $transformation1 = new Transformation(); $transformation1->add($filter1, 5)->add($filter2, -3)->add($filter3); $expected1 = array($filter2, $filter3, $filter1); $transformation2 = new Transformation(); $transformation2->add($filter1)->add($filter2)->add($filter3); $expected2 = array($filter1, $filter2, $filter3); $this->assertSame($expected1, $transformation1->getFilters()); $this->assertSame($expected2, $transformation2->getFilters()); }
public function actionIndex() { exit; $imagesPath = Yii::app()->uploadManager->getBasePath() . DIRECTORY_SEPARATOR . 'realty' . DIRECTORY_SEPARATOR; $imagine = Imagine::getImagine(); $transformation = new Transformation(); $transformation->add(new Watermark($imagine, Yii::getPathOfAlias('webroot') . '/uploads/watersign.png')); if (file_exists($imagesPath)) { try { foreach (glob($imagesPath . '*.JPG') as $key => $path) { if ($key > 200) { break; } $transformation->apply($imagine->open($path))->save(); } echo "success!!!"; } catch (Exception $e) { echo 'Save operation failed: ' . $path . '<br />'; } } }
/** * Test if filter throws exception via Transformation without * passing Imagine instance. * * @expectedException \Imagine\Exception\InvalidArgumentException */ public function testFilterThrowsExceptionViaTransformation() { $filters = new Transformation(); $filters->add(new DummyImagineAwareFilter()); $filters->apply($this->getImage()); }