System requirements
Install and deploy Integration/image
Add in composer.json [require] section, then execute composer update
<span>"</span><span>intervention/image</span><span>"</span>: <span>"</span><span>2.0.15</span><span>"</span>
Laravel Configuration
After the installation and deployment of Integration/image is completed, open the configuration file config/app.php and add code in the corresponding location, and then the Image class will be automatically loaded and available for use. It's powerful enough to handle almost all your image processing needs.
<span>//</span><span>服务提供器</span> <span>'</span><span>Intervention\Image\ImageServiceProvider</span><span>'</span> <span>//</span><span>别名配置</span> <span>'</span><span>Image</span><span>'</span> => <span>'</span><span>Intervention\Image\Facades\Image</span><span>'</span>
Configuration settings
By default, Integration/Image uses PHP's GD library extension. If you want to switch to imagick, you can use php artisan to create a configuration file to add the corresponding configuration.
$ php artisan config:publish intervention/imag
Basic use
A few basic functions are listed here. For more detailed instructions, please check the relevant interface documents.
1. Display a picture
Route::get('/', <span>function</span><span>() { </span><span>$img</span> = Image::make('foo.jpg')->resize(300, 200<span>); </span><span>return</span> <span>$img</span>->response('jpg'<span>); });</span>
2. Read an image file
<span>$img</span> = Image::make('foo/bar/baz.jpg');
3. Draw a picture
<span>$img</span> = Image::canvas(800, 600, '#ccc');
4. Edit a picture
<span>$img</span> = Image::make('foo.jpg')->resize(320, 240)->insert('watermark.png');