Skip to content

Commit

Permalink
Merge pull request #503 from wodka/master
Browse files Browse the repository at this point in the history
implement interlace filter
  • Loading branch information
makasim committed Jan 8, 2015
2 parents cf1aadd + 35851b9 commit 7e71457
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 2 deletions.
23 changes: 23 additions & 0 deletions Imagine/Filter/Loader/InterlaceFilterLoader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Liip\ImagineBundle\Imagine\Filter\Loader;

use Imagine\Image\ImageInterface;

class InterlaceFilterLoader implements LoaderInterface
{
/**
* {@inheritDoc}
*/
public function load(ImageInterface $image, array $options = array())
{
$mode = ImageInterface::INTERLACE_LINE;
if (!empty($options['mode'])) {
$mode = $options['mode'];
}

$image->interlace($mode);

return $image;
}
}
5 changes: 5 additions & 0 deletions Resources/config/imagine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<parameter key="liip_imagine.filter.loader.background.class">Liip\ImagineBundle\Imagine\Filter\Loader\BackgroundFilterLoader</parameter>
<parameter key="liip_imagine.filter.loader.upscale.class">Liip\ImagineBundle\Imagine\Filter\Loader\UpscaleFilterLoader</parameter>
<parameter key="liip_imagine.filter.loader.auto_rotate.class">Liip\ImagineBundle\Imagine\Filter\Loader\AutoRotateFilterLoader</parameter>
<parameter key="liip_imagine.filter.loader.interlace.class">Liip\ImagineBundle\Imagine\Filter\Loader\InterlaceFilterLoader</parameter>

<!-- Data loaders' classes -->

Expand Down Expand Up @@ -181,6 +182,10 @@
<tag name="liip_imagine.filter.loader" loader="auto_rotate" />
</service>

<service id="liip_imagine.filter.loader.interlace" class="%liip_imagine.filter.loader.interlace.class%">
<tag name="liip_imagine.filter.loader" loader="interlace" />
</service>

<!-- Data loaders -->

<service id="liip_imagine.binary.loader.prototype.filesystem" class="%liip_imagine.binary.loader.filesystem.class%">
Expand Down
14 changes: 14 additions & 0 deletions Resources/doc/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ liip_imagine:
my_thumb:
filters:
auto_rotate: ~
### The `interlace` filter

Set progressive loading on the image
Configuration looks like this:

``` yaml
liip_imagine:
filter_sets:
my_thumb:
filters:
interlace:
# mode can be one of none,line,plane,partition
mode: line
```
## Load your Custom Filters

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Liip\ImagineBundle\Tests\Functional\Imagine;
namespace Liip\ImagineBundle\Tests\Functional\Imagine\Data;

use Liip\ImagineBundle\Tests\Functional\WebTestCase;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Liip\ImagineBundle\Tests\Functional\Imagine;
namespace Liip\ImagineBundle\Tests\Functional\Imagine\Filter;

use Liip\ImagineBundle\Tests\Functional\WebTestCase;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Liip\ImagineBundle\Tests\Functional\Imagine\Filter\Loader;

use Liip\ImagineBundle\Tests\Functional\WebTestCase;

class InterlaceFilterLoaderTest extends WebTestCase
{
public function testCouldBeGetFromContainerAsService()
{
$this->createClient();
$service = self::$kernel->getContainer()->get('liip_imagine.filter.loader.interlace');

$this->assertInstanceOf('Liip\ImagineBundle\Imagine\Filter\Loader\InterlaceFilterLoader', $service);
}
}

28 changes: 28 additions & 0 deletions Tests/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Liip\ImagineBundle\Tests\Filter;

use Liip\ImagineBundle\Imagine\Filter\Loader\InterlaceFilterLoader;
use Liip\ImagineBundle\Tests\AbstractTest;

/**
* @covers Liip\ImagineBundle\Imagine\Filter\Loader\InterlaceFilterLoader
*/
class InterlaceFilterLoaderTest extends AbstractTest
{
public function testLoad()
{
$loader = new InterlaceFilterLoader();

$image = $this->getMockImage();
$image
->expects($this->once())
->method('interlace')
->with('TEST')
;

$result = $loader->load($image, array('mode' => 'TEST'));

$this->assertInstanceOf('Imagine\Image\ImageInterface', $result);
}
}

0 comments on commit 7e71457

Please sign in to comment.