intervention/image-tempest

Tempest framework integration of Intervention Image

Maintainers

Package info

github.com/Intervention/image-tempest

Homepage

pkg:composer/intervention/image-tempest

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

4.0.0 2026-04-18 13:34 UTC

This package is auto-updated.

Last update: 2026-04-18 13:55:41 UTC


README

Tempest framework integration for Intervention Image

Latest Version Tests Monthly Downloads Support me on Ko-fi

This package provides an integration to setup Intervention Image easily to your Tempest application with a publishable configuration.

Requirements

  • Tempest >= 3.9

Installation

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

composer require intervention/image-tempest

Features

Although Intervention Image can be used with Tempest without this extension, this integration package includes the following features that make image interaction with the framework much easier.

Application-wide configuration

This integration package comes with a global configuration file that is recognized by Tempest. It is therefore possible to store the settings for Intervention Image once centrally and not have to define them individually each time you call the image manager.

The configuration file can be copied to the application with the following command.

php tempest install image

The call will publish the configuration file image.config.php to your local application. Here you can set the desired driver and its configuration options for Intervention Image.

The configuration files looks like this.

use Intervention\Image\Drivers\Gd\Driver as GdDriver;
use Intervention\Image\Tempest\Config as ImageConfig;

return new ImageConfig(
    /*
    |--------------------------------------------------------------------------
    | Image Driver
    |--------------------------------------------------------------------------
    |
    | Intervention Image supports “GD Library” and “Imagick” to process images
    | internally. Depending on your PHP setup, you can choose one of them.
    |
    | Included options:
    |   - \Intervention\Image\Drivers\Gd\Driver::class
    |   - \Intervention\Image\Drivers\Imagick\Driver::class
    |   - \Intervention\Image\Drivers\Vips\Driver::class
    */

    driver: \Tempest\env('IMAGE_DRIVER', GdDriver::class),

    /*
    |--------------------------------------------------------------------------
    | Configuration Options
    |--------------------------------------------------------------------------
    |
    | These options control the behavior of Intervention Image.
    |
    | - "autoOrientation" controls whether an imported image should be
    |    automatically rotated according to any existing Exif data.
    |
    | - "decodeAnimation" decides whether a possibly animated image is
    |    decoded as such or whether the animation is discarded.
    |
    | - "backgroundColor" Defines the default background & blending color.
    |
    | - "strip" controls if meta data like exif tags should be removed when
    |    encoding images.
    */

    autoOrientation: true,
    decodeAnimation: true,
    backgroundColor: 'ffffff',
    strip: false,
);

You can read more about the different options for driver selection, setting options for auto orientation, decoding animations and background color.

Injecting Dependencies

The following code example shows how to inject an image manager into your controller. The instance has already been automatically configured according to the config file. Of course you are not limited to inject into controller.

use Intervention\Image\Format;
use Intervention\Image\Interfaces\ImageManagerInterface;
use Tempest\Router\Get;
use Tempest\View\View;

use function Tempest\View\view;

final readonly class HomeController
{
    public function __construct(private ImageManagerInterface $imageManager)
    {
        //
    }

    #[Get(uri: '/')]
    public function __invoke(): View
    {
        // process image
        $image = $this->imageManager
            ->decode('./example.jpg')
            ->scale(height: 300)
            ->encodeUsingFormat(Format::WEBP);

        return view('./home.view.php', dataUri: $image->toDataUri());
    }
}

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 Tempest is licensed under the MIT License.