Skip to content
This repository
Browse code

Merge pull request #123 from ardianys/develop

Add crop filter implementation
  • Loading branch information...
commit 919b188bf72e1b2e5469fdc66df74a936936d8f3 2 parents e53bc4a + 151e1f1
Bulat Shakirzyanov authored March 17, 2013
20  Imagine/Filter/Loader/CropFilterLoader.php
... ...
@@ -0,0 +1,20 @@
  1
+<?php
  2
+
  3
+namespace Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader;
  4
+
  5
+use Imagine\Image\Box;
  6
+use Imagine\Image\Point;
  7
+
  8
+use Imagine\Filter\Basic\Crop;
  9
+use Imagine\Image\ImageInterface;
  10
+
  11
+class CropFilterLoader implements LoaderInterface
  12
+{
  13
+    public function load(array $options = array())
  14
+    {
  15
+        list($x, $y) = $options['start'];
  16
+        list($width, $height) = $options['size'];
  17
+
  18
+        return new Crop(new Point($x, $y), new Box($width, $height));
  19
+    }
  20
+}
14  README.md
Source Rendered
@@ -313,6 +313,18 @@ avalanche_imagine:
313 313
 
314 314
 ```
315 315
 
  316
+### Crop
  317
+
  318
+The `crop` filter crop an image with start coordinate, and size dimension.
  319
+
  320
+``` yaml
  321
+avalanche_imagine:
  322
+    filters:
  323
+        crop:
  324
+            type   : crop
  325
+            options: { start: [0, 0], size: [100, 100] } #crop image with 100x100 square box
  326
+```
  327
+
316 328
 ## Load your Custom Filters
317 329
 
318 330
 The ImagineBundle allows you to load your own custom filter classes. The only
@@ -369,4 +381,4 @@ $avalancheService = $this->get('imagine.cache.path.resolver');
369 381
 Then, call the getBrowserPath and pass the original image webpath and the filter you want to use
370 382
 ```php
371 383
 $cachedImage = $avalancheService->getBrowserPath($object->getWebPath(), 'my_thumb');
372  
-```
  384
+```
6  Resources/config/imagine.xml
@@ -49,6 +49,8 @@
49 49
 
50 50
         <parameter key="imagine.filter.loader.chain.class">Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader\ChainFilterLoader</parameter>
51 51
 
  52
+        <parameter key="imagine.filter.loader.crop.class">Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader\CropFilterLoader</parameter> 
  53
+        
52 54
     </parameters>
53 55
 
54 56
     <services>
@@ -135,6 +137,10 @@
135 137
             <argument type="service" id="imagine.filter.manager" />
136 138
             <tag name="imagine.filter.loader" filter="chain" />
137 139
         </service>
  140
+        
  141
+        <service id="imagine.filter.loader.crop" class="%imagine.filter.loader.crop.class%">
  142
+            <tag name="imagine.filter.loader" filter="crop" />
  143
+        </service>
138 144
 
139 145
     </services>
140 146
 </container>

0 notes on commit 919b188

Please sign in to comment.
Something went wrong with that request. Please try again.