Laravel 使用 intervention image 包上傳、剪裁圖片

  1. 通過 composer 安裝 composer intervention/image
  2. 修改 config/app.php 文件,添加 $providers$aliases
    ‘Intervention\Image\ImageServiceProvider’
    ‘Image’ => ‘Intervention\Image\Facades\Image’
  3. 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');

參考資料

ORM-based file upload package for php. http://codesleeve.com https://github.com/CodeSleeve/stapler

在Laravel項目中實現Ajax上傳用戶頭像

發佈了34 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章