• Laravel 使用 Intervention/image 配置和修改驱动 imagick


    基本环境要求

    环境需求:

    • PHP >= 5.4
    • Fileinfo Extension
    • Laravel >=5.0

    拓展包需求:

    • GD Library (>=2.0) … or …
    • Imagick PHP extension (>=6.5.7)

    安装

    前提:你已经安装好laravel 项目,且当前在项目目录

    comoposer 安装 intervention/image

    php composer.phar require intervention/image

    在Laravel 中注册 intervention/image

    1.打开 config/app.php 文件 

    2.在 'providers' =>[...] 添加以下(容器服务注册)

    InterventionImageImageServiceProvider::class
    3.在 'aliases' =>[...] 添加以下(门面注册:[可以直接使用Image::make()])
    'Image' => InterventionImageFacadesImage::class

     4.enjoy!

    修改驱动为imagick (默认为GD驱动--可以不做配置)

    执行命令:

    php artisan vendor:publish --provider="InterventionImageImageServiceProviderLaravelRecent"

    这时你的config目录下会多出一个image.php 

    将 'driver' => 'gd' 改为  'driver' => 'imagick' 即可

    文件如下:

    <?php
    
    return [
    
        /*
        |--------------------------------------------------------------------------
        | Image Driver
        |--------------------------------------------------------------------------
        |
        | Intervention Image supports "GD Library" and "Imagick" to process images
        | internally. You may choose one of them according to your PHP
        | configuration. By default PHP's "GD Library" implementation is used.
        |
        | Supported: "gd", "imagick"
        |
        */
    
        'driver' => 'imagick'
    
    ];

    使用范例:

    // usage inside a laravel route
    Route::get('/', function()
    {
        $img = Image::make('foo.jpg')->resize(300, 200);
    
        return $img->response('jpg');
    });

    以上内容参考 Intervention/image 官网:http://image.intervention.io/getting_started/installation

  • 相关阅读:
    JQuery Ajax实例总结
    【水】HDU 2099——整除的尾数
    hdu 1540 Tunnel Warfare(线段树区间统计)
    python学习教程(九)sqlalchemy框架的modern映射
    Maven 实现Struts2注解配置步骤详解
    消息机4
    hdu4708
    【每日一摩斯】-Troubleshooting: High CPU Utilization (164768.1)
    poj1860 解题报告
    机器学习理论与实战(十六)概率图模型04
  • 原文地址:https://www.cnblogs.com/zjhblogs/p/12170594.html
Copyright © 2020-2023  润新知