diff --git a/Assetic/Filter/ImagineFilter.php b/Assetic/Filter/ImagineFilter.php
new file mode 100644
index 0000000..03e7d4e
--- /dev/null
+++ b/Assetic/Filter/ImagineFilter.php
@@ -0,0 +1,87 @@
+imagine = $imagine;
+ $this->filterManager = $filterManager;
+ $this->imagineFilter = $imagineFilter;
+ }
+
+ /**
+ * Not in use
+ *
+ * @param AssetInterface $asset The asset
+ *
+ * @return void
+ */
+ public function filterLoad(AssetInterface $asset)
+ {
+ }
+
+ /**
+ * Main logic is located here.
+ * We parse the css here and create for all matching images a seperate asset
+ *
+ * @param AssetInterface $asset The asset
+ *
+ * @return void
+ */
+ public function filterDump(AssetInterface $asset)
+ {
+ ob_start();
+ try {
+ $format = $this->filterManager->getOption($this->imagineFilter, "format", "png");
+
+ $this->filterManager->getFilter($this->imagineFilter)
+ ->apply($this->imagine->load($asset->getContent()))
+ ->show($format);
+
+ $asset->setContent(ob_get_clean());
+ } catch (\Exception $e) {
+ @ob_end_clean();
+ throw $e;
+ }
+ }
+}
diff --git a/AvalancheImagineBundle.php b/AvalancheImagineBundle.php
index 828ca31..bbe4694 100644
--- a/AvalancheImagineBundle.php
+++ b/AvalancheImagineBundle.php
@@ -3,6 +3,7 @@
namespace Avalanche\Bundle\ImagineBundle;
use Avalanche\Bundle\ImagineBundle\DependencyInjection\Compiler\LoadersCompilerPass;
+use Avalanche\Bundle\ImagineBundle\DependencyInjection\Compiler\AsseticCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
@@ -16,5 +17,6 @@ public function build(ContainerBuilder $container)
parent::build($container);
$container->addCompilerPass(new LoadersCompilerPass());
+ $container->addCompilerPass(new AsseticCompilerPass());
}
}
diff --git a/DependencyInjection/Compiler/AsseticCompilerPass.php b/DependencyInjection/Compiler/AsseticCompilerPass.php
new file mode 100644
index 0000000..a031323
--- /dev/null
+++ b/DependencyInjection/Compiler/AsseticCompilerPass.php
@@ -0,0 +1,30 @@
+hasDefinition('assetic.filter_manager')) {
+ return;
+ }
+
+ $filters = $container->getParameter('imagine.filters');
+ $asseticFilterManagerDef = $container->getDefinition('assetic.filter_manager');
+ foreach($filters as $name => $options) {
+ if (isset($options['options']) && isset($options['options']['assetic']) && ((bool) $options['options']['assetic'] === true )) {
+ $filterName = 'imagine_' . $name;
+ $filterClass = new DefinitionDecorator('imagine.assetic.filter');
+ $filterClass->replaceArgument(2, $name);
+ $container->setDefinition('imagine.assetic.filter.' . $filterName, $filterClass);
+ $asseticFilterManagerDef->addMethodCall('set', array($filterName, new Reference('imagine.assetic.filter.' . $filterName)));
+ }
+ }
+ }
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..90f1dfe
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2004-2013 Bulat Shakirzyanov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/README.md b/README.md
index 9137787..6262adf 100644
--- a/README.md
+++ b/README.md
@@ -369,4 +369,21 @@ $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');
-```
\ No newline at end of file
+```
+
+## Using in combination with assetic
+
+If you want to render static images with assetic, but want to leverage the image manipulation features
+of imagine you can enable on a per filter basis assetic support.
+
+``` yaml
+filters:
+ filtername:
+ options: { assetic: true }
+```
+
+If you enable assetic for a filter the filter will be available as an assetic filter with the imagine filters name,
+prefixed by "imagine_" as in our example "imagine_filtername".
+
+Assetic has some name restriction this restriction apply here too, which means, the filtername
+can only contain A-Z, 0-9 and underscores. This affects only filters with enabled assetic support.
\ No newline at end of file
diff --git a/Resources/config/imagine.xml b/Resources/config/imagine.xml
index 88607e1..208b77b 100644
--- a/Resources/config/imagine.xml
+++ b/Resources/config/imagine.xml
@@ -12,6 +12,9 @@
media/cache
+
+ Avalanche\Bundle\ImagineBundle\Assetic\Filter\ImagineFilter
+
Avalanche\Bundle\ImagineBundle\Imagine\Filter\FilterManager
@@ -52,7 +55,14 @@
-
+
+
+
+
+
+
+
+