Home > PHP Framework > Laravel > Laravel uses the intervention image package to upload and crop images

Laravel uses the intervention image package to upload and crop images

藏色散人
Release: 2020-07-29 13:29:00
forward
5812 people have browsed it

The following tutorial column from Laravel will introduce to you how Laravel uses the intervention image package to upload and crop images. I hope it will be helpful to friends in need!

Laravel uses the intervention image package to upload and crop images

1. Install through composer composer intervention/image

2. Modify the config/app.php file and add $providers and $aliases
'Intervention\Image\ImageServiceProvider'

'Image' => 'Intervention\Image\Facades\Image'

1. By default Intervention Image uses PHP's GD library extension to process all images. If you want to switch to Imagick, you can pull a configuration file into your application by running on of the following artisan command.

Publish configuration in Laravel 5

$ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"

Handling image uploads in Laravel

In a Laravel application it is also possible to pass an uploaded file directly to the make method.

Creating Image from File Upload in Laravel

// resizing an uploaded file
Image::make(Input::file('photo'))->resize(300, 200)->save('foo.jpg')
Copy after login

The above is the detailed content of Laravel uses the intervention image package to upload and crop images. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template