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

在 Laravel 5.2 中調(diào)整圖像大小

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

問題描述

誰能幫助我如何在 Laravel 中實現(xiàn)調(diào)整圖像大小?

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 沒有默認的圖像大小調(diào)整.但是大多數(shù) Laravel 開發(fā)人員使用圖像干預"來處理圖像.它易于使用.

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 數(shù)組中,添加以下內(nèi)容:

In the $providers array, add the following:

InterventionImageImageServiceProvider::class

在 $aliases 數(shù)組中,添加以下內(nèi)容:

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 中調(diào)整圖像大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數(shù))
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數(shù)中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內(nèi)容必須是實現(xiàn) __toString()、“boolean和“boolean的字符串或?qū)ο?移動到 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())
主站蜘蛛池模板: 在线观看国产 | 午夜视频在线播放 | 国产东北一级毛片 | 亚洲午夜视频 | 日韩免费中文字幕 | 91精品国产色综合久久不卡98口 | 国产一区在线免费观看视频 | 国产精品免费大片 | 欧美日韩在线免费 | 99久久精品免费看国产小宝寻花 | 精品亚洲永久免费精品 | 亚洲福利在线观看 | 精品日韩电影 | 黄网站涩免费蜜桃网站 | 中文字幕日韩一区二区 | 午夜国产在线 | 久www | 最大av在线| 欧美一区二区三区 | 日韩久久网 | 国产精品久久久久久久久久久免费看 | 欧美日本高清 | 一级片免费观看 | 亚洲精品一区二区 | 欧美日韩中文在线 | 天天干天天草 | 国产伦精品一区二区三区四区视频 | 日日日操 | 手机av网 | 色综合国产 | 成人福利网站 | 91亚洲一区 | 国产精品成人一区 | 91欧美精品 | 午夜精品一区二区三区免费视频 | 久久一区视频 | 亚洲成人黄色 | 国产精品毛片av | 特黄小视频 | 国产欧美精品一区二区色综合朱莉 | 国产一区二区三区在线 |