Nginx 教程

主要文档

Nginx功能概述 为什么选择Nginx Nginx安装 常见问题(FAQ) 配置符号参考 调试 nginx 优化 Nginx 运行和控制Nginx

核心模块

Nginx事件模块 Nginx主模块

基本模块

Browser模块 Charset模块 Geo模块 HttpAccess模块 HttpAuthBasic模块 HttpAutoindex模块 HttpEmptyGif模块 HttpFcgi模块 HttpGzip模块 HttpHeaders模块 HttpIndex模块 HttpIndex模块. HttpLimit zone HttpLimitReqest模块 HttpLog模块 HttpProxy模块 HttpRewrite模块 HttpSSI模块 HttpUserId http核心模块 map Memcached

其他模块

Addition模块 EmbeddedPerl flv GooglePerftools HttpDav模块 HttpGeoIP HttpGzipStatic HttpImageFilter HttpRealIp HttpSecureLink HttpSSL HttpSubstitution HttpXSLT RandomIndex StubStatus模块

mail模块

MailAuth MailCore MailProxy MailSSL

安装

nginx php-fpm安装配置 nginx在fedora上的安装 nginx在freebsd上的安装 nginx在ubuntu上的安装 nginx在windows上的安装

配置示例和方法

HWLoadbalancerCheckErrors nginx防盗链 负载均衡 完整例子 完整例子2 虚拟主机

HttpImageFilter


Version: 0.7.54+

This module is a filter for transforming JPEG, GIF and PNG images. It is not enabled by default to enable it, provide this option to ./configure when building nginx:
这个模块用来分发JPEG,GIF和PNG图片。这个没有默认开启,在编译nginx中通过./configure参数配置

--with-http_image_filter_module 

libgd is required to build and run the module. We recommend using the latest version of libgd.
编译和运行这个模块必须安装libgd库。我们推荐使用最新版本的Libgd.

Example Configuration

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

}

location = /empty {
    empty_gif;
} 

指令

image_filter

Syntax:*image_filter (test|size|resize width height|crop width height)*

Default:*none*

Context:*location*

Specifies the type of transformation to apply to the image, one of the below:
详细的图片后缀类型如下:

  • test: checking that the response is indeed an image format JPEG, GIF or PNG. Otherwise, an error 415.
    测试:测试确定图片文件的后缀格式为JPEG,GIF OR PNG。否则返回415错误

  • size: Gives information about the image in JSON format. For example,
    尺寸:返回JSON格式的图片信息。例如:

{ "img" : { "width": 100, "height": 100, "type": "gif" } } 

Or if an error occurs,
或者如果发生错误,

{} 
  • resize: proportionally reduces the image to a specified size.
    调整大小:缩略图片到特定的尺寸

  • crop: proportionally reduces the image to a specified size and trims extra edge.
    切割:切割图片到特定的尺寸和特定的分辨率

image_filter_buffer

Syntax:*image_filter_buffer size*

Default:*1M*

Context:*http, server, location*

Sets the maximum size for reading the image.
设置读取文件的最大的尺寸

image_filter_jpeg_quality

Syntax:*image_filter_jpeg_quality [0...100]*

Default:*75*

Context:*http, server, location*

Sets the rate of loss of information when processing the images as JPEG. The maximum recommended value is 95.
设置处理JPEG图片的丢失信息率.推荐的最大值为95

image_filter_transparency

Syntax:*image_filter_transparency on|off*

Default:*on*

Context:*http, server, location*

This directive allows you to disable image transparency in GIF and palette-based PNG to improve image resampling quality.
这个指令容许你关闭GIF图片的透明度和 PNG图片质量

True color PNG alpha-channels are always preserved despite this setting.
真彩色PNG图片保存忽略设定

Note: Grayscale PNG's are untested, but should be handled as truecolor PNGs.
注释:灰度PNG图片未被设置,但应该被作为真彩色PNG图片处理

References

Original Documentation