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

Added PasteFilterLoader #118

Merged
merged 4 commits into from
Feb 13, 2013
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
27 changes: 27 additions & 0 deletions Imagine/Filter/Loader/PasteFilterLoader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Liip\ImagineBundle\Imagine\Filter\Loader;

use Imagine\Image\Point;
use Imagine\Image\ImageInterface;
use Imagine\Image\ImagineInterface;

class PasteFilterLoader implements LoaderInterface
{
public function __construct(ImagineInterface $imagine, $rootPath)
{
$this->imagine = $imagine;
$this->rootPath = $rootPath;
}

/**
* @see Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface::load()
*/
public function load(ImageInterface $image, array $options = array())
{
list($x, $y) = $options['start'];
$destImage = $this->imagine->open($this->rootPath.'/'.$options['image']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about checking whether the $options['image'] is already an Imagine\Image\ImageInterface and use this directly? If it's not, the current line is just fine.


return $image->paste($destImage, new Point($x, $y));
}
}
7 changes: 7 additions & 0 deletions Resources/config/imagine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<parameter key="liip_imagine.filter.loader.resize.class">Liip\ImagineBundle\Imagine\Filter\Loader\ResizeFilterLoader</parameter>
<parameter key="liip_imagine.filter.loader.thumbnail.class">Liip\ImagineBundle\Imagine\Filter\Loader\ThumbnailFilterLoader</parameter>
<parameter key="liip_imagine.filter.loader.crop.class">Liip\ImagineBundle\Imagine\Filter\Loader\CropFilterLoader</parameter>
<parameter key="liip_imagine.filter.loader.paste.class">Liip\ImagineBundle\Imagine\Filter\Loader\PasteFilterLoader</parameter>

<!-- Data loaders' classes -->

Expand Down Expand Up @@ -131,6 +132,12 @@
<tag name="liip_imagine.filter.loader" loader="crop" />
</service>

<service id="liip_imagine.filter.loader.paste" class="%liip_imagine.filter.loader.paste.class%">
<tag name="liip_imagine.filter.loader" loader="paste" />
<argument type="service" id="liip_imagine" />
<argument>%kernel.root_dir%</argument>
</service>

<!-- Data loaders -->

<service id="liip_imagine.data.loader.filesystem" class="%liip_imagine.data.loader.filesystem.class%">
Expand Down