@@ -23,16 +23,29 @@ In your existing Laravel application you can install this package using [Compose
23
23
composer require intervention/image-laravel
24
24
```
25
25
26
- Next, add the configuration files to your application using the ` vendor:publish ` command:
26
+ ## Features
27
+
28
+ Although Intervention Image can be used with Laravel without this extension,
29
+ this intergration package includes the following features that make image
30
+ interaction with the framework much easier.
31
+
32
+ ### Application-wide configuration
33
+
34
+ The extension comes with a global configuration file that is recognized by
35
+ Laravel. It is therefore possible to store the settings for Intervention Image
36
+ once centrally and not have to define them individually each time you call the
37
+ image manager.
38
+
39
+ The configuration file can be copied to the application with the following command.
27
40
28
41
``` bash
29
42
php artisan vendor:publish --provider=" Intervention\Image\Laravel\ServiceProvider"
30
43
```
31
44
32
- This command will publish the configuration file ` image.php ` for the image
33
- integration to your ` app/config ` directory. In this file you can set the
34
- desired driver and its configuration options for Intervention Image. By default
35
- the library is configured to use GD library for image processing.
45
+ This command will publish the configuration file ` config/ image.php` . Here you
46
+ can set the desired driver and its configuration options for Intervention
47
+ Image. By default the library is configured to use GD library for image
48
+ processing.
36
49
37
50
The configuration files looks like this.
38
51
@@ -89,24 +102,50 @@ You can read more about the different options for
89
102
[ decoding animations] ( https://image.intervention.io/v3/modifying/animations ) and
90
103
[ blending color] ( https://image.intervention.io/v3/basics/colors#transparency ) .
91
104
92
- ## Getting started
105
+ ### Static Facade Interface
93
106
94
- The integration is now complete and it is possible to access the [ ImageManager] ( https://image.intervention.io/v3/basics/instantiation )
95
- via Laravel's facade system. The package also includes a response macro that can be used to elegantly convert an image resource into an HTTP response.
107
+ This package also integrates access to Intervention Image's central entry
108
+ point, the ` ImageManager::class ` , via a static [ facade] ( https://laravel.com/docs/11.x/facades ) . The call provides access to the
109
+ centrally configured [ image manager] ( https://image.intervention.io/v3/basics/instantiation ) via singleton pattern.
110
+
111
+ The following code example shows how to read an image with the image facade in a Laravel route.
96
112
97
113
``` php
114
+ use Illuminate\Support\Facades\Route;
115
+ use Illuminate\Support\Facades\Storage;
98
116
use Intervention\Image\Laravel\Facades\Image;
99
- use Intervention\Image\Format;
100
117
101
118
Route::get('/', function () {
102
119
$image = Image::read(Storage::get('example.jpg'))
103
- ->place(resource_path('images/watermark.png'));
120
+ ->resize(300, 200);
121
+ });
122
+ ```
123
+
124
+ ### Image Response Macro
125
+
126
+ Furthermore, the package also includes a response macro that can be used to
127
+ elegantly convert an image resource into an HTTP response.
128
+
129
+ The following code example shows how to read an image from a upload request
130
+ place and use the image response macro to encode it and send the image back to
131
+ the user in one call. Only the first parameter is required.
132
+
133
+ ``` php
134
+ use Illuminate\Http\Request;
135
+ use Illuminate\Support\Facades\Route;
136
+ use Illuminate\Support\Facades\Storage;
137
+ use Intervention\Image\Laravel\Facades\Image;
138
+
139
+ Route::get('/', function (Request $request) {
140
+ $upload = $request->file('image');
141
+ $image = Image::read($request)
142
+ ->scale(300, 200);
104
143
105
144
return response()->image($image, Format::WEBP, quality: 65);
106
145
});
107
146
```
108
147
109
- Read the [ official documentation of Intervention Image] ( https://image.intervention.io ) for more information .
148
+ You can read more about intervention image in general in the [ official documentation of Intervention Image] ( https://image.intervention.io ) .
110
149
111
150
## Authors
112
151
0 commit comments