安装

composer require intervention/image

使用文档http://image.intervention.io/getting_started/introduction

类库

<?php
/*
 * 图片处理
 */

namespace app\common\services;

use Intervention\Image\ImageManager;

class ImageService {

    //client
    protected $client;

    public function __construct() {
        $this->client = new ImageManager(array('driver' => $this->getClient()));
    }

    /*
     * 本地用gd库,线上用imagick
     */
    protected function getClient() {

        if (\think\Env::get('APP_LOCAL') == 'LOCAL') {
            return 'gd';
        } else {
            return 'imagick';
        }
    }

    /*
     * 适合—合并裁剪和调整大小
     *  top-left
        top
        top-right
        left
        center (default)
        right
        bottom-left
        bottom
        bottom-right
     */
    public function fit($file = '',$width = 0,$height = 0,$callback = null,$position = 'center') {
        return $this->client->make($file)->fit($width,$height,$callback,$position);
    }

}

nginx 解析php conf配置文件

本博客的nginx 配置文件 server { listen 80;#80和443端口同时监听 listen 443 ssl; server_name www.koukousky.com koukousky.com...

阅读全文

php composer 安装阿里云镜像

#doc: https://developer.aliyun.com/composer 全局配置(推荐) composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 取消配...

阅读全文

intervention/image处理IOS上传图片翻转问题

#安装 $ composer require intervention/image <?php use Intervention\Image\ImageManagerStatic as Image; //test.png要处理的图片路径 Image::make(&...

阅读全文

欢迎留言