久久久久久久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热欧美 | 日韩综合一区 | 国产大学生情侣呻吟视频 | 国产一区二区三区在线看 | 成人免费视频久久 | 亚洲精品片 | 国产精品亚洲综合 | 国产日韩中文字幕 | 久久亚洲国产精品日日av夜夜 | 亚洲一区视频在线 | 粉嫩一区二区三区四区公司1 | 色噜噜狠狠色综合中国 | 在线高清免费观看视频 | 麻豆精品国产免费 | 亚州精品天堂中文字幕 | 国产精品久久久久久网站 | 91一区| 97视频在线观看免费 | 成人在线精品视频 | 久久国产视频一区 | 亚洲一区电影 | 日本又色又爽又黄又高潮 | 中文字幕91av| 97精品超碰一区二区三区 | 精精国产xxxx视频在线播放7 | 国产欧美日韩一区 | 午夜久久久久久久久久一区二区 | 黄色片免费 | 国产午夜精品久久久 | 精品欧美一区二区三区久久久 | 国产精品久久久久无码av | 久久精品国产一区二区电影 | 国产剧情一区二区三区 | 亚洲一区二区三区视频免费观看 | 欧美久久免费观看 | 欧美精品一区二区在线观看 | 欧美一区二区三区在线观看 | 国产精品视频播放 | 中国美女撒尿txxxxx视频 | 国产精品国产精品 |