Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement interlace filter #503

Merged
merged 1 commit into from
Jan 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -171,6 +172,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);
}
}