zoukankan      html  css  js  c++  java
  • [Nginx]使用ngx_http_image_filter_module实现压缩图片为缩略图

    ubuntu系统下,先安装ngx_http_image_filter_module这个模块

    先看看自己的源

    cat /etc/apt/sources.list.d/nginx-stable.list

    deb http://nginx.org/packages/ubuntu/ xenial nginx
    deb-src http://nginx.org/packages/ubuntu/ xenial nginx

    apt-get install -y nginx nginx-module-image-filter

    在/etc/nginx/nginx.conf 的开头部分引入模块

    load_module modules/ngx_http_image_filter_module.so;

    配置vhost

    例如我这个例子,一定注意看if判断部分 , 语法错误也不行,这个就是当传递width和height参数的时候,就按照参数的进行裁剪

        location ~* .*.(JPG|jpg|gif|png|PNG)$ {
            root /var/www/html/go-fly2;
            # 图片默认高度
           set $width -;  
            # 图片默认高度
            set $height -;  
            if ( $arg_width != "" ) { 
                    set $width $arg_width;
            }   
            if ( $arg_height != "" ) { 
                    set $height $arg_height;
            }   
            image_filter test;
        
            image_filter resize $width $height; 
            image_filter_buffer 100M;  
            image_filter_jpeg_quality 95; 
    } 

    https://xxxx/xxxxx.jpg?width=100

    类似上面这样调用

    开源作品

    GO-FLY,一套可私有化部署的免费开源客服系统,安装过程不超过五分钟(超过你打我 !),基于Golang开发,二进制文件可直接使用无需搭开发环境,下载zip解压即可,仅依赖MySQL数据库,是一个开箱即用的网页在线客服系统,致力于帮助广大开发者/中小站长快速整合私有客服功能
    github地址:go-fly
    官网地址:https://gofly.sopans.com

    赞赏作者

    微信交流

  • 相关阅读:
    学习 iOS多线程开发 Demo示意
    python(数字Number)
    python(元组)
    python(列表)
    python(一)
    APP自动化测试框架搭建(转载)
    Appium真机运行Device Name获取方法
    关于android sdk manager在下载包时没有android intel x86 atom system image等项
    adb shell命令查看当前与用户交互的activity
    SDK更新
  • 原文地址:https://www.cnblogs.com/taoshihan/p/14801697.html
Copyright © 2011-2022 走看看