Skip to content

Commit 6fe9483

Browse files
committed
Improve readme
1 parent b924bec commit 6fe9483

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

README.md

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,29 @@ In your existing Laravel application you can install this package using [Compose
2323
composer require intervention/image-laravel
2424
```
2525

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.
2740

2841
```bash
2942
php artisan vendor:publish --provider="Intervention\Image\Laravel\ServiceProvider"
3043
```
3144

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.
3649

3750
The configuration files looks like this.
3851

@@ -89,24 +102,50 @@ You can read more about the different options for
89102
[decoding animations](https://image.intervention.io/v3/modifying/animations) and
90103
[blending color](https://image.intervention.io/v3/basics/colors#transparency).
91104

92-
## Getting started
105+
### Static Facade Interface
93106

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.
96112

97113
```php
114+
use Illuminate\Support\Facades\Route;
115+
use Illuminate\Support\Facades\Storage;
98116
use Intervention\Image\Laravel\Facades\Image;
99-
use Intervention\Image\Format;
100117

101118
Route::get('/', function () {
102119
$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);
104143

105144
return response()->image($image, Format::WEBP, quality: 65);
106145
});
107146
```
108147

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).
110149

111150
## Authors
112151

0 commit comments

Comments
 (0)