Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support animated gif #466

Merged
merged 1 commit into from
Aug 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
13 changes: 10 additions & 3 deletions Imagine/Filter/FilterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public function apply(BinaryInterface $binary, array $config)
$config = array_replace(
array(
'filters' => array(),
'quality' => 100
'quality' => 100,
'animated' => false
),
$config
);
Expand All @@ -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']) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we force it? what if we set it for no gif images, what would be get?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "force it"? I have no idea if its working with non-gif-images...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is to get the value from the config, here for the gif you always force it to be true. I think has to be taken as is from the config and any assumptions are done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it. fixed with the latest push.

$options['animated'] = $config['animated'];
}

$filteredContent = $image->get($binary->getFormat(), $options);

return new Binary($filteredContent, $binary->getMimeType(), $binary->getFormat());
}
Expand Down
2 changes: 2 additions & 0 deletions Resources/doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ liip_imagine:
name:
path: ~
quality: 100
animated: false
format: ~
cache: ~
data_loader: ~
Expand Down Expand Up @@ -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)