Skip to content

Feature/config #4

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

Merged
merged 5 commits into from
Jun 15, 2024
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
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,27 @@ return [
## Configuration

By default, the bundle is configured to use the GD library with Intervention
Image. However, the package also offers other drivers. This can be easily
configured by creating a file `config/packages/intervention_image.yaml` and
Image. However, the package also offers other drivers. This and other options of the
library can be easily configured by creating a file `config/packages/intervention_image.yaml` and
setting the driver class as follows.

```yaml
intervention_image:
driver: Intervention\Image\Drivers\Imagick\Driver
options:
autoOrientation: true
decodeAnimation: true
blendingColor: 'ffffff'
```

You can choose between the two supplied drivers `Intervention\Image\Drivers\Gd\Driver` and
`Intervention\Image\Drivers\Imagick\Driver` for example.

You can read more about the different options for
[auto orientation](https://image.intervention.io/v3/modifying/effects#image-orientation-according-to-exif-data),
[decoding animations](https://image.intervention.io/v3/modifying/animations) and
[blending color](https://image.intervention.io/v3/basics/colors#transparency).

## Getting Started

The integration is now complete and it is possible to access the [ImageManager](https://image.intervention.io/v3/basics/instantiation)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"require": {
"php": "^8.1",
"intervention/image": "^3.5",
"intervention/image": "^3.7",
"symfony/framework-bundle": "^6.4|^7"
},
"autoload": {
Expand Down
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ services:
autowire: true
arguments:
$driver: '%intervention_image.driver%'
$options: '%intervention_image.options%'
9 changes: 8 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ public function getConfigTreeBuilder(): TreeBuilder
$treeBuilder->getRootNode()
->children()
->scalarNode('driver')
->defaultValue(GdDriver::class)
->defaultValue(GdDriver::class)
->end()
->arrayNode('options')->addDefaultsIfNotSet()
->children()
->booleanNode('autoOrientation')->defaultValue(true)->end()
->booleanNode('decodeAnimation')->defaultValue(true)->end()
->scalarNode('blendingColor')->defaultValue('ffffff')->end()
->end()
->end()
->end();

Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/InterventionImageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$container->setParameter('intervention_image.driver', $config['driver']);
$container->setParameter('intervention_image.options', $config['options']);
}
}