Nginx模块参考手册:Image Filter模块(Image Filter)

如果要使用这些模块,则必须在编译时指定相关的编译参数。

这个模块可以在传递图片文件(">JPEG, GIF和PNG)时对其做一些改变 。
要使用这个模块必须在编译时指定下列编译参数(0.7.54后版本可用):

--with-http_image_filter_module

这个模块依赖于libgd,推荐使用近期的版本。
示例配置:

location /img/ { proxy_pass http://backend; image_filter resize 150 100; error_page 415 = /empty;} location = /empty { empty_gif;}

指令

image_filter

语法:image_filter (test|size|resize width height|crop width height)
默认值:none
使用字段:location
指定需要变化的类型。如下:

test: 核实应答确实为一个图片格式,否则返回415错误。 size: JSON格式的图片信息,如:{ "img" : { "width": 100, "height": 100, "type": "gif" } }

或许是一个错误:

{} resize:减少图片到指定
大小。 crop:减少图片到指定大小并对超过大小的部分进行裁剪。

image_filter_buffer

语法:image_filter_buffer size
默认值:1M
使用字段:http, server, location
读取图片的最大值。

image_filter_jpeg_quality

语法:image_filter_jpeg_quality [0…100]
默认值:75
使用字段:http, server, location
设置处理JPEG图片时损失的质量比率,最大推荐值为95。

image_filter_transparency

语法:image_filter_transparency on|off
默认值:on
使用字段:http, server, location
这个指令允许你在GIF和基于调色板的PNG中禁用图像透明,以提高图像质量。
无论是否设置这个参数,真色彩PNG的alpha通道总是存在。
注意:灰度PNG并未经过测试,它将作为真色彩进行处理。

时间: 2024-08-04 09:52:13

Nginx模块参考手册:Image Filter模块(Image Filter)的相关文章

Nginx模块参考手册:Map模块(Map)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. 这个模块允许你分类或者同时映射多个值到多个不同值并储存到一个变量中,map指令用来创建变量,但是仅在变量被接受的时候执行视图映射操作,对于处理没有引用变量的请求,这个模块并没有性能上的缺失. 如下例: map $http_host $name { hostnames; default 0; example.com 1; *.example.com 1; test.com 2; *.test.com 2; .si

Nginx模块参考手册:日志模块(Log)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. 控制nginx如何记录请求日志.例: log_format gzip '$remote_addr - $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_user_agent" "$gzip_ratio"'; access

Nginx模块参考手册:SSI模块(SSI)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. 这个模块为处理服务器端包含(SSI)的输入提供一个过滤器,目前所支持的SSI命令并不完善.如下例: location / { ssi on;} 指令 ssi 语法:ssi [ on | off ] 默认值:ssi off 使用字段:http, server, location, location中的if字段 启用SSI处理.注意如果启用SSI,那么Last-Modified头和Content-Length头不会

Nginx模块参考手册:Scgi模块(Scgi)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. 这个模块允许nginx同Scgihttp://www.aliyun.com/zixun/aggregation/18521.html">协同工作,并且控制哪些参数将被安全传递,这个页面基本是拷贝自FastCGI与proxy,所以并不一定完全准确.这个模块最早可用于版本0.8.42.例: location / { include scgi_params; scgi_pass localhost: 9000;

Nginx模块参考手册:Geo模块(Geo)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. 这个模块创建一些变量,其值依赖于客户端的IP地址:如下例: geo $geo { default 0; 127.0.0.1/32 2; 192.168.1.0/24 1; 10.1.0.0/16 1;} 指令 geo 语法:geo [$ip_variable] $variable { - } 默认值:none 使用字段:http 这个指令指定了一个客户端IP的所属国家,默认情况下它会查找$remote_addr

Nginx模块参考手册:uWSGI模块(uWSGI)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. 为uwsgi协议提供支持.示例配置: location / { uwsgi_pass unix:///var/run/example.com.sock; include uwsgi_http://www.aliyun.com/zixun/aggregation/12616.html">params; } 注意不要把uwsgi协议和uWSGI服务器混淆. 指令 uwsgi_pass 语法:uwsgi_pas

Nginx模块参考手册:FastCGI模块(FastCGI)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. &http://www.aliyun.com/zixun/aggregation/37954.html">nbsp; 这个模块允许nginx同FastCGI协同工作,并且控制哪些参数将被安全传递.例: location / { fastcgi_pass localhost:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /h

Nginx模块参考手册:Memcached模块(Memcached)

这些模块默认会全部编译进Nginx,除非手工指定某个模块在configure时排除. 使用这个模块简单的处理缓存.示例配置: server { location / { set $memcached_key $uri; memcached_pass http://www.aliyun.com/zixun/aggregation/11696.html">name:11 211; default_type text/html; error_page 404 = /fallback; } loc

Nginx模块参考手册:主模块(Main Module)

摘要 包含一些Nginx的基本控制功能 指令 daemon 语法:daemon on | off默认值:on daemon off; 生产环境中不要使用"daemon"和"master_process"指令,这些指令仅用于开发调试.虽然可以使用daemon off在生产环境中,但对性能提升没有任何帮助,但是在生产环境中永远不要使用master_process off. env 语法:env VAR|VAR=VALUE默认值:TZ使用字段:main这个命令允许其限定一

Nginx模块参考手册:第三方模块(3rd Party Modules)

这些模块虽然没有正式被官方支持,但是可以http://www.aliyun.com/zixun/aggregation/17185.html">帮助用户完成不少的功能.使用过程中请自行承担遇到的问题.在nginx源代码目录中使用下列命令添加第三方模块: ./configure --add-module=/path/to/module1/source \            --add-module=/path/to/module2/source 可以根据需求使用多个–add-module