编译:

./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. Excel Old format or invalid type library 错误原因

    Old format or invalid type library 错误原因 调用excel方法失败,Old format or invalid type library 解决方案: 1,这是Exc ...

  2. Tensorflow学习教程------下载图像识别模型inceptionV3

    # coding: utf-8 import tensorflow as tf import os import tarfile import requests #inception模型下载地址 in ...

  3. python 知识点补充

    python 知识点补充 简明 python 教程 r 或 R 来指定一个 原始(Raw) 字符串 Python 是强(Strongly)面向对象的,因为所有的一切都是对象, 包括数字.字符串与 函数 ...

  4. TPO1-2 The Origin of Theater

    Stories (myths) may then grow up around a ritual. Frequently the myths include representatives of th ...

  5. 实战_4:UI开发工具-WindowBuilder

    介绍: WindowBuilder是谷歌开发的,开发java图形界面的工具,是一个eclipse插件. WindowBuilder支持开发多种形式的图形界面:SWT/JFace.Swing.GWT 安 ...

  6. E - Apple Tree(树状数组+DFS序)

    There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. ...

  7. mysql关键字汇总

    ADD ALL ALTER ANALYZE AND AS ASC ASENSITIVE BEFORE BETWEEN BIGINT BINARY BLOB BOTH BY CALL CASCADE C ...

  8. mac用python读取文件常见问题(未完成)

    python读取文件常见问题(mac版) 让python的默认编码,和文件的编码保持一致

  9. The equal-likelihood model|event|experiment|probability model

    5.1Probability Basics uncertainty is inherent in inferential statistics,因为总是需要样本估计总体,The science of ...

  10. 复杂的Polygon