### Install Intervention Image Laravel Package Source: https://github.com/intervention/image-laravel/blob/develop/README.md This Composer command installs the `intervention/image-laravel` package into your Laravel application, making the Intervention Image library and its Laravel integration available for use. ```bash composer require intervention/image-laravel ``` -------------------------------- ### Serve Modified Image as HTTP Response with Intervention Image Macro Source: https://github.com/intervention/image-laravel/blob/develop/README.md Illustrates the use of Intervention Image's response macro to read an image from storage, apply modifications (scaling), and directly return it as an HTTP response. The example encodes the image to WEBP format with a specified quality. ```php use IlluminateSupportFacadesRoute; use IlluminateSupportFacadesStorage; use InterventionImageFormat; use InterventionImageLaravelFacadesImage; Route::get('/', function () { $image = Image::read(Storage::get('example.jpg')) ->scale(300, 200); return response()->image($image, Format::WEBP, quality: 65); }); ``` -------------------------------- ### Intervention Image Laravel Configuration File Example Source: https://github.com/intervention/image-laravel/blob/develop/README.md This PHP array represents the default configuration file for Intervention Image within a Laravel application. It defines the image processing driver and various options that control image behavior, such as auto-orientation, animation decoding, blending color, and metadata stripping. ```php return [ /* |-------------------------------------------------------------------------- | 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 | */ 'driver' => \Intervention\Image\Drivers\Gd\Driver::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. | | - "blendingColor" Defines the default blending color. | | - "strip" controls if meta data like exif tags should be removed when | encoding images. */ 'options' => [ 'autoOrientation' => true, 'decodeAnimation' => true, 'blendingColor' => 'ffffff', 'strip' => false, ] ]; ``` -------------------------------- ### Intervention Image Laravel Configuration Options Reference Source: https://github.com/intervention/image-laravel/blob/develop/README.md Detailed documentation for the configurable options available in the `config/image.php` file, allowing global control over the Intervention Image library's behavior within a Laravel application. ```APIDOC Config File: config/image.php Key: 'driver' Type: string (class path) Description: Specifies the image processing driver to use internally. Available Options: - \Intervention\Image\Drivers\Gd\Driver::class (Default) - \Intervention\Image\Drivers\Imagick\Driver::class Key: 'options' Type: array Description: Contains various behavioral options that control image processing. Sub-Keys: - Key: 'autoOrientation' Type: boolean Description: Controls whether an imported image should be automatically rotated according to any existing Exif data. Default: true - Key: 'decodeAnimation' Type: boolean Description: Decides whether a possibly animated image is decoded as such or whether the animation is discarded. Default: true - Key: 'blendingColor' Type: string (hexadecimal color code, e.g., 'ffffff') Description: Defines the default blending color used in various image operations. Default: 'ffffff' - Key: 'strip' Type: boolean Description: Controls if metadata (like Exif tags) should be removed when encoding images. Default: false ``` -------------------------------- ### Publish Intervention Image Laravel Configuration File Source: https://github.com/intervention/image-laravel/blob/develop/README.md This Artisan command publishes the default configuration file for Intervention Image Laravel to `config/image.php`. This allows developers to customize the image driver (GD or Imagick) and other processing options globally for their application. ```bash php artisan vendor:publish --provider="Intervention\Image\Laravel\ServiceProvider" ``` -------------------------------- ### Process and Save Uploaded Image with Intervention Image Facade Source: https://github.com/intervention/image-laravel/blob/develop/README.md Demonstrates how to use the Intervention Image Laravel facade to read an uploaded image from a request, resize it, and save it to disk with a random filename. It utilizes Laravel's Request, Storage, and Str helpers for file handling and naming. ```php use IlluminateHttpRequest; use IlluminateSupportFacadesRoute; use IlluminateSupportFacadesStorage; use IlluminateSupportStr; use InterventionImageLaravelFacadesImage; Route::get('/', function (Request $request) { $upload = $request->file('image'); $image = Image::read($upload) ->resize(300, 200); Storage::put( Str::random() . '.' . $upload->getClientOriginalExtension(), $image->encodeByExtension($upload->getClientOriginalExtension(), quality: 70) ); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.