zoukankan      html  css  js  c++  java
  • nginx添加图片处理工具

    nginx添加图片处理工具

    • 查看nginx信息 nginx -V,下载相同版本nginx解压并编译
    • configure编译时追加参数--with-http_image_filter_module,执行make命令
    • 备份原来nginx可执行文件,复制objs目录的nginx文件,到nginx sbin 目录
    • 配置 nginx.conf
    
    location ~ .*.(gif|jpg|jpeg|png)?filter$ {
      # 图片默认宽度
      set $w -;
      # 图片默认高度
      set $h -;
      if ($arg_w != "") {
        set $w $arg_w;
      }
      if ($arg_h != "") {
        set $h $arg_h;
      }
      image_filter resize  $w $h;
      image_filter crop $w $h;
      image_filter_jpeg_quality 75;
      image_filter_buffer  10M;
      try_files /$1.$2 /notfound.jpg;
      expires 30d;
      access_log off;
    }
    
    location ~* /(.+).(jpg|jpeg|gif|png)!(d+)x(d+)$ {
      set $w $3;
      set $h $4;
      image_filter resize  $w $h;
      image_filter crop $w $h;
      image_filter_jpeg_quality 75;
      image_filter_buffer  10M;
      try_files /$1.$2 /notfound.jpg;
      expires 30d;
      access_log off;
    }
    location ~ .*.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico|woff2|svg)$ {
      expires 30d;
      access_log off;
    }
    
    
  • 相关阅读:
    【Linux】命令——基本命令
    正则表达式
    Letex
    Markdown
    文本编辑器Vim
    【Linux】集群
    【Linux】软件安装
    共线性synteny
    windows触控手势
    【Linux】bin结尾的安装包
  • 原文地址:https://www.cnblogs.com/stringfade/p/15247736.html
Copyright © 2011-2022 走看看