Use the Image processing library Integration/Image in Laravel

Source: Internet
Author: User
Tags image processing library
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.