From babe61290fe6b8190d78de34da4a8e26f1b5bb6c Mon Sep 17 00:00:00 2001 From: Patrick Landolt Date: Tue, 29 Jul 2014 18:04:56 +0200 Subject: [PATCH] support animated gif animated value from config --- DependencyInjection/Configuration.php | 1 + Imagine/Filter/FilterManager.php | 13 ++++++++++--- Resources/doc/configuration.md | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 198a8918d..20edc03b7 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -119,6 +119,7 @@ public function getConfigTreeBuilder() ->fixXmlConfig('filter', 'filters') ->children() ->scalarNode('quality')->defaultValue(100)->end() + ->booleanNode('animated')->defaultFalse()->end() ->scalarNode('cache')->defaultNull()->end() ->scalarNode('data_loader')->defaultNull()->end() ->arrayNode('filters') diff --git a/Imagine/Filter/FilterManager.php b/Imagine/Filter/FilterManager.php index 9ba5a5467..69dcf6193 100644 --- a/Imagine/Filter/FilterManager.php +++ b/Imagine/Filter/FilterManager.php @@ -71,7 +71,8 @@ public function apply(BinaryInterface $binary, array $config) $config = array_replace( array( 'filters' => array(), - 'quality' => 100 + 'quality' => 100, + 'animated' => false ), $config ); @@ -88,9 +89,15 @@ public function apply(BinaryInterface $binary, array $config) $image = $this->loaders[$eachFilter]->load($image, $eachOptions); } - $filteredContent = $image->get($binary->getFormat(), array( + $options = array( 'quality' => $config['quality'] - )); + ); + + if ($binary->getFormat() === 'gif' && $config['animated']) { + $options['animated'] = $config['animated']; + } + + $filteredContent = $image->get($binary->getFormat(), $options); return new Binary($filteredContent, $binary->getMimeType(), $binary->getFormat()); } diff --git a/Resources/doc/configuration.md b/Resources/doc/configuration.md index 1476b0cfa..21b733fed 100644 --- a/Resources/doc/configuration.md +++ b/Resources/doc/configuration.md @@ -29,6 +29,7 @@ liip_imagine: name: path: ~ quality: 100 + animated: false format: ~ cache: ~ data_loader: ~ @@ -81,5 +82,6 @@ Each filter set that you specify has the following options: default: empty array - `format` - hardcodes the output format (aka the requested format is ignored) + - `animated` - support for resizing animated gif (currently not supported by Imagine (PR pending)) [Back to the index](index.md)