编译:

./configure --prefix=/usr/local/nginx
--with-http_stub_status_module --with-http_realip_module
--with-http_image_filter_module --with-debug

配置:

location ~* /(\d+).(jpg)$ {
  set $h $arg_h;
  set $w $arg_w;
  image_filter resize $h $w;
}
location ~* /(\d+)_(\d+)x(\d+)\.(jpg)$ {
  if ( -e $document_root/$.$) {
    rewrite /(\d+)_(\d+)x(\d+)\.(jpg)$ /$.$?h=$&w=$ last;
  }
  return ;
}

参数:test 返回是否真的是图片
size:返回图片长短尺寸,返回json格式数据
corp:截取图片的一部分,从左上角开始截取
resize:缩放图片,等比例缩放
优点:根据传入参数即可生成各种比例图片
不占用任何磁盘空间
缺点:消耗cpu,访问量大会给服务器带来极大的负担

Nginx笔记总结十七:nginx生成缩略图配置(http_image_filter_module)的更多相关文章

  1. Nginx 整合 Lua 实现动态生成缩略图

    原文地址:Nginx 整合 Lua 实现动态生成缩略图 博客地址:http://www.extlight.com 一.前提 最近在开发一个项目,涉及到缩略图的功能,常见的生成缩略图的方案有以下几个: ...

  2. Nginx 笔记与总结(3)配置虚拟主机

    Nginx 重启的另外一种方式,相当于 kill -HUP `cat /usr/local/nginx/logs/nginx.pid`: /usr/local/nginx/sbin/nginx -s ...

  3. Nginx 笔记与总结(4)配置 server 访问日志

    打开 nginx.conf: [root@localhost ~]# cd /usr/local/nginx/conf [root@localhost conf]# vim nginx.conf 在默 ...

  4. Nginx笔记总结一:基本安装和配置

    1. Nginx安装 下载地址和安装依赖包 http://nginx.org/download/nginx-1.9.14.tar.gz yum -y install pcre pcre-devel z ...

  5. Nginx笔记总结九:Nginx日志配置

    ngx_http_log_module用来定义请求日志格式1. access_log指令 语法:   access_log path [format [buffer=size [flush=time] ...

  6. Nginx笔记总结五:Nginx配置虚拟主机

    upstream proxy1 { server ; } upstream proxy2 { server ; } server { listen ; server_name www1.dlab.co ...

  7. Nginx笔记总结六:Nginx location配置

    语法规则:location [= | ~ | ~* | ^~] /uri/ {....} = 表示精确匹配 ^~ 表示uri以某个常规字符串开头 ~ 表示区分大小写的正则表达式 ~* 表示不区分大小写 ...

  8. Nginx笔记总结二:Nginx编译参数

    -prefix=                                                    安装路径-with-http_ssl_module               ...

  9. Nginx笔记总结十三:nginx 正向代理

    server { listen ; location / { resolver 202.106.0.20 202.106.119.116; resolver_timeout 30s; proxy_pa ...

随机推荐

  1. ZOJ 3735 dp

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3735 好久没做DP题了,一开始没理解题目里的C(M,3)是干什么,原来就是 ...

  2. rpc框架解释

    远程过程调用协议RPC(Remote Procedure Call Protocol) RPC是指远程过程调用,也就是说两台服务器A,B,一个应用部署在A服务器上,想要调用B服务器上应用提供的函数/方 ...

  3. nvm安装教程

    nvm是一个nodejs的版本管理工具 默认安装位置  C:\Users\userName\AppData\Roaming\nvm x   1 C:\Users\userName\AppData\Ro ...

  4. c语言中assert的用法

    /************************************************************************* > File Name: assert.c ...

  5. ZJNU 2206 - 染色

    开纵横两个结构体数组,记录连续涂了一整行或者一整列的情况 再开一个map,记录涂点 #include<iostream> #include<algorithm> #includ ...

  6. requset请求处理与BeanUtils封装

    HTTP: 概念:Hyper Text Transfer Protocol 超文本传输协议 传输协议:定义了,客户端和服务器端通信时,发送数据的格式 特点: 基于TCP/IP的高级协议 默认端口号:8 ...

  7. [Algo] 223. Add Two Numbers

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  8. 包-logging-hashlib-深浅拷贝

    一.包: 包的本质就是一个模块 什么是包:它是一系列模块文件的结合体,表示形式就是一个文件夹,该文件夹内部通常会有一个__init__..py的文件 导入包的过程:先产生一个执行文件的名称空间 1:创 ...

  9. 903C. Boxes Packing#俄罗斯套娃问题(map使用)

    题目出处:http://codeforces.com/problemset/problem/903/C 题目大意:求这组数据中数据出现的最大重复次数 #include<iostream> ...

  10. Matlab高级教程_第三篇:Matlab转码C/C++方式(混编)_第二部分

    这一部分通过一些实例来进行转码和调试的讲解: 1. 输入变量.输出变量和过程内变量的内存预分配 函数代码:函数名test function [A,B] = test( mark,num,array ) ...