Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 39 additions and 1 deletion.
  1. +20 −0 Imagine/Filter/Loader/CropFilterLoader.php
  2. +13 −1 README.md
  3. +6 −0 Resources/config/imagine.xml
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>

No commit comments for this range

Something went wrong with that request. Please try again.