系統(tǒng)需求
安裝部署 Integration/image在 composer.json [require] 節(jié)增加,之后執(zhí)行 composer update
"intervention/image": "2.0.15"
Laravel 配置
安裝部署 Integration/image 完成后,打開配置文件 config/app.php 在相應(yīng)位置添加代碼,然后 Image 類就能自動(dòng)加載并可供使用了。其功能強(qiáng)大到可以處理你的幾乎所有圖片處理需求。
//服務(wù)提供器'Intervention/Image/ImageService配置設(shè)置默認(rèn)情況下, Integration/Image 使用PHP的GD庫(kù)擴(kuò)展。如果你想切換到 imagick,你可以使用 php artisan 創(chuàng)建一個(gè)配置文件以添加相應(yīng)的配置。
$ php artisan config:publish intervention/imag基本使用
這里列出幾個(gè)基本功能,更詳細(xì)使用說明請(qǐng)查看相關(guān)接口文檔。1、顯示一張圖片
Route::get('/', function(){ $img = Image::make('foo.jpg')->resize(300, 200); return $img->response('jpg');});2、讀取一個(gè)圖片文件
$img = Image::make('foo/bar/baz.jpg');3、繪制一張圖片
$img = Image::canvas(800, 600, '#ccc');4、編輯一張圖片
$img = Image::make('foo.jpg')->resize(320, 240)->insert('watermark.png');
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注