Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #123 from ardianys/develop

Add crop filter implementation
  • Loading branch information...
commit 919b188bf72e1b2e5469fdc66df74a936936d8f3 2 parents e53bc4a + 151e1f1
@avalanche123 authored
View
20 Imagine/Filter/Loader/CropFilterLoader.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader;
+
+use Imagine\Image\Box;
+use Imagine\Image\Point;
+
+use Imagine\Filter\Basic\Crop;
+use Imagine\Image\ImageInterface;
+
+class CropFilterLoader implements LoaderInterface
+{
+ public function load(array $options = array())
+ {
+ list($x, $y) = $options['start'];
+ list($width, $height) = $options['size'];
+
+ return new Crop(new Point($x, $y), new Box($width, $height));
+ }
+}
View
14 README.md
@@ -313,6 +313,18 @@ avalanche_imagine:
```
+### Crop
+
+The `crop` filter crop an image with start coordinate, and size dimension.
+
+``` yaml
+avalanche_imagine:
+ filters:
+ crop:
+ type : crop
+ options: { start: [0, 0], size: [100, 100] } #crop image with 100x100 square box
+```
+
## Load your Custom Filters
The ImagineBundle allows you to load your own custom filter classes. The only
@@ -369,4 +381,4 @@ $avalancheService = $this->get('imagine.cache.path.resolver');
Then, call the getBrowserPath and pass the original image webpath and the filter you want to use
```php
$cachedImage = $avalancheService->getBrowserPath($object->getWebPath(), 'my_thumb');
-```
+```
View
6 Resources/config/imagine.xml
@@ -49,6 +49,8 @@
<parameter key="imagine.filter.loader.chain.class">Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader\ChainFilterLoader</parameter>
+ <parameter key="imagine.filter.loader.crop.class">Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader\CropFilterLoader</parameter>
+
</parameters>
<services>
@@ -135,6 +137,10 @@
<argument type="service" id="imagine.filter.manager" />
<tag name="imagine.filter.loader" filter="chain" />
</service>
+
+ <service id="imagine.filter.loader.crop" class="%imagine.filter.loader.crop.class%">
+ <tag name="imagine.filter.loader" filter="crop" />
+ </service>
</services>
</container>
Please sign in to comment.
Something went wrong with that request. Please try again.