Nginx 의 httpimage_filter_module 모듈 사용

3346 단어 nginx
설치 하 다
#yum install gd-devel
#
#./configure --prefix=/usr/local/nginx     \
#  --with-debug                            \
#  --with-http_stub_status_module          \
#  --with-http_ssl_module                  \
#  --with-http_realip_module               \
#  --with-http_image_filter_module         \
#  --with-pcre=../pcre-8.21                \
#  --add-module=../ngx_devel_kit-0.2.19    \
#  --add-module=../lua-nginx-module-0.9.8  \
#  --add-module=../echo-nginx-module       \
#  --add-module=../redis2-nginx-module     \
#  --add-module=../set-misc-nginx-module

배치
        location ~* (.*\.(jpg|gif|png))!(.*)!(.*)$ {
            set $width   $3;
            set $height  $4;
            rewrite "(.*\.(jpg|gif|png))(.*)$" $1;
        }

        location ~* /image/.*\.(jpg|gif|png)$ {
            root   /home/jfy/web/;
            #image_filter off;
            #image_filter test;
            #image_filter size;
            #image_filter rotate 90;
            image_filter resize $width $height;
            #image_filter crop 300 200;
            image_filter_buffer 10M;
            image_filter_interlace on;
            image_filter_jpeg_quality 95;
            image_filter_sharpen 100;
            image_filter_transparency on;
        }
image_filter off;
#    

image_filter test;
#     jpeg gif png   415  

image_filter size;
#       json  :    { "img" : { "width": 100, "height": 100, "type": "gif" } }     :{}

image_filter rotate 90|180|270;
#         ,        ,      resize crop    。

image_filter resize width height;
#            ,           "-"   ,  415,        ,   rotate    ,       。

image_filter crop width height;
#                         ,   rotate  。    

image_filter_buffer 10M;
#             ,   415  。

image_filter_interlace on;
#    ,         。  JPEG,       “   JPEG”  。

image_filter_jpeg_quality 95;
#     JPEG       。       1 100    。                ,      ,       95。         。

image_filter_sharpen 100;
#           。         100。       。         。

image_filter_transparency on;
#           GIF   PNG             ,    。                。 PNG Alpha         。

셋째,
몇 가지 규칙 이 유용 할 수 있다.
           
---------------------------------------------------------
        location ~* \.(jpg|gif|png)$ {
            image_filter resize 500 500;
        }
---------------------------------------------------------

          
---------------------------------------------------------
        location ~* /image/.*\.(jpg|gif|png)$ {
            image_filter resize 500 500;
        }
---------------------------------------------------------

    url   
---------------------------------------------------------
        location ~* (.*\.(jpg|gif|png))!(.*)!(.*)$ {
            set $width      $3;
            set $height     $4;
            rewrite "(.*\.(jpg|gif|png))(.*)$" $1;
        }
        
        location ~* /image/.*\.(jpg|gif|png)$ {
            image_filter resize $width $height;
        }
---------------------------------------------------------
http://172.16.18.114/image/girl.jpg!300!200
        300*200   

상세 효과 참조 가능:http://cwtea.blog.51cto.com/blog/4500217/1333142

좋은 웹페이지 즐겨찾기