: This article describes how to use the image processing library IntegrationImage in Laravel. For more information about PHP tutorials, see. System requirements
- PHP >=5.3
- Fileinfo Extension
- GD Library (> = 2.0 )... Or...
- Imagick PHP extension (> = 6.5.7)
Install and deploy Integration/image
Added in composer. json [require], and then executed composer update
"intervention/image": "2.0.15"
Laravel configuration
After the Integration/image installation and deployment is complete, open the configuration file config/app. php and add code in the corresponding location. then the Image class will be automatically loaded and available. It is powerful enough to handle almost all your image processing needs.
// Service provider 'Intervention \ Image \ imageserviceprovider' // alias configuration 'image' => 'Intervention \ Image \ Facades \ image'
Configuration settings
By default, Integration/Image uses the GD Library extension of PHP. 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 usage
Several basic functions are listed here. For more detailed instructions, see the relevant interface documentation.
1. display an image
Route::get('/', function(){ $img = Image::make('foo.jpg')->resize(300, 200); return $img->response('jpg');});
2. read an image file
$img = Image::make('foo/bar/baz.jpg');
3. draw an image
$img = Image::canvas(800, 600, '#ccc');
4. edit an image
$img = Image::make('foo.jpg')->resize(320, 240)->insert('watermark.png');
The above introduces the use of the Image processing library Integration/Image in Laravel, including some content, and hope to be helpful to friends who are interested in PHP tutorials.