久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Laravel 5.2 中調整圖像大小

Resize image in Laravel 5.2(在 Laravel 5.2 中調整圖像大小)
本文介紹了在 Laravel 5.2 中調整圖像大小的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

誰能幫助我如何在 Laravel 中實現調整圖像大小?

Can anyone help me how to implement resizing image in Laravel?

我只有這個代碼:

if($request->hasFile('image')){
    if (Input::file('image')->isValid()) {
        $file = Input::file('image');
        $destination = base_path() . '/public/images/ServiceImages';
        $extension = Input::file('image')->getClientOriginalExtension();
        $fileName = rand(111,99999).'.'.$extension;

        if(!empty($data['Image'])){
            unlink($destination.$data['Image']);
        }

        $file->move($destination, $fileName);
        $service->image=$fileName;
    }
}

推薦答案

Laravel 沒有默認的圖像大小調整.但是大多數 Laravel 開發人員使用圖像干預"來處理圖像.它易于使用.

Laravel does not have a default resize of image. But most Laravel developers use 'Image intervention' in handling the image. It is easy to use.

安裝(圖像干預):

第一步運行

composer require intervention/image

第 2 步在您的 config/app.php 上:

STEP 2 On your config/app.php:

在 $providers 數組中,添加以下內容:

In the $providers array, add the following:

InterventionImageImageServiceProvider::class

在 $aliases 數組中,添加以下內容:

In the $aliases array,add the following:

'Image' => InterventionImageFacadesImage::class

如果您遇到 GD 庫丟失的問題,請安裝它

If you have problems your GD library is missing, install it

  • PHP5:sudo apt-get install php5-gd
  • PHP7:sudo apt-get install php7.0-gd

在您的控制器上使用.

第 3 步

在您的控制器之上

使用 InterventionImageImageManagerStatic 作為圖像;

第 4 步

關于你的方法(有幾種方法,但這會給你一個想法)

On your method (there are several ways but this will give you an idea)

if($request->hasFile('image')) {

    $image       = $request->file('image');
    $filename    = $image->getClientOriginalName();

    $image_resize = Image::make($image->getRealPath());              
    $image_resize->resize(300, 300);
    $image_resize->save(public_path('images/ServiceImages/' .$filename));

}

參考這里.

這篇關于在 Laravel 5.2 中調整圖像大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數)
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內容必須是實現 __toString()、“boolean和“boolean的字符串或對象.移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 在线一区二区国产 | 欧美一级电影免费 | 夜夜草天天草 | 福利网址| 午夜成人免费视频 | 日本免费一区二区三区 | 欧美精品一区二区三区四区五区 | 99久久视频| 狠狠操天天干 | 91久久国产综合久久 | 亚洲成人一级 | 不卡视频一区 | 黑人精品欧美一区二区蜜桃 | 国产一区二区电影 | 亚洲成人自拍网 | 欧美成人精品一区二区男人看 | 久久精品一区 | 久久毛片| 一区中文字幕 | 亚洲男人天堂 | 精品三级在线观看 | 91久久国产综合久久 | 一区二区在线观看免费视频 | 国产精品久久久久久 | 韩国av一区二区 | 毛片a级毛片免费播放100 | 精品一二三区视频 | 一级做a| 一级高清免费毛片 | 精品日韩欧美一区二区 | 99热这里都是精品 | 99精品欧美一区二区蜜桃免费 | 国精产品一品二品国精在线观看 | 一区二区三区四区在线免费观看 | 午夜小电影 | 精品久久久久久 | 久久小视频 | 国产 欧美 日韩 一区 | 欧美亚洲国产一区二区三区 | 先锋影音资源网站 | 国产中文字幕网 |