/** * @param int $margin * @param string $color * @param int $alpha * @return self */ public function frame($margin = 20, $color = '666', $alpha = 100) { \Yii::trace('frame file', __METHOD__); $this->mark(__METHOD__, func_get_args()); $this->save(function () use($margin, $color, $alpha) { return Image::frame($this->File->getAbsolutePath(), $margin, $color, $alpha); }); return $this; }
public function testManipulations() { $Image = File\models\File::getNoImage()->image(); list($absolute_path, $web_path) = $Image->crop(10, 20)->result; $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); $this->assertTrue(file_exists($absolute_path)); $size = getimagesize($absolute_path); $this->assertNotEmpty($size); $this->assertEquals($size[0], 10); $this->assertEquals($size[1], 20); $this->assertEquals((string) $Image->crop(10, 20), $web_path); list($absolute_path, $web_path) = $Image->resize(30, 40)->result; $size = getimagesize($absolute_path); $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); $this->assertEquals($size[0], 30); $this->assertEquals($size[1], 40); list($absolute_path, $web_path) = $Image->resizeByWidth(50)->result; $size = getimagesize($absolute_path); $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); $this->assertEquals($size[0], 50); $this->assertEquals($size[1], 50); list($absolute_path, $web_path) = $Image->resizeByHeight(100)->result; $size = getimagesize($absolute_path); $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); $this->assertEquals($size[0], 100); $this->assertEquals($size[1], 100); list($absolute_path, $web_path) = $Image->thumbnail(120, 120)->result; $size = getimagesize($absolute_path); $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); $this->assertEquals($size[0], 120); $this->assertEquals($size[1], 120); list($absolute_path, $web_path) = $Image->text('test', \Yii::getAlias('@yiiunit/data/DejaVuSans.ttf'))->result; $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); list($absolute_path, $web_path) = $Image->watermark(\Yii::getAlias('@yiiunit/data/watermark.png'))->result; $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); list($absolute_path, $web_path) = $Image->frame()->result; $size = getimagesize($absolute_path); $this->assertNotEmpty($absolute_path); $this->assertNotEmpty($web_path); $this->assertEquals($size[0], 552); $this->assertEquals($size[1], 552); }