Skip to content

Intervention/image-symfony

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intervention Image Symfony

Symfony Integration for Intervention Image

Latest Version Monthly Downloads Support me on Ko-fi

This package provides an integration to setup Intervention Image easily to your Symfony framework application. Although the use of this integration library is not absolutely necessary, it offers a convenient way of central configuration in the Symfony framework.

Requirements

  • Symfony >= 6.4

Installation

In your existing Symfony application you can install this package using Composer.

composer require intervention/image-symfony

After successful installation, you can activate the bundle in the file config/bundes.php of your application by inserting the following line into the array.

return [
    // ...
    Intervention\Image\Symfony\InterventionImageBundle::class => ['all' => true],
];

Configuration

By default, the bundle is configured to use the GD library with Intervention 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.

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, decoding animations and blending color.

Getting Started

The integration is now complete and it is possible to access the ImageManager via dependency injection.

namespace App\Controller;

use Intervention\Image\ImageManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class ExampleController extends AbstractController
{
    #[Route('/')]
    public function example(ImageManager $manager): Response
    {
        $image = $manager->read('images/example.jpg');
    }
}

Read the official documentation of Intervention Image for more information.

Authors

This library is developed and maintained by Oliver Vogel

Thanks to the community of contributors who have helped to improve this project.

License

Intervention Image Symfony is licensed under the MIT License.