Nginx图片剪裁模块探究 http(2)

{ "img" : { "width": 1920, "height": 1200, "type": "jpeg" } }

test2:

{ "img" : { "width": 1920, "height": 1080, "type": "jpeg" } }

test3:

{ "img" : { "width": 354, "height": 586, "type": "png" } }

输出json格式,可以用来调用。

image_filter_buffer size;

我们试试超过1M的文件

415 Unsupported Media Type

品茶:这个值看你怎么设了,因为iphone现在拍的原图基本上是4-8M左右

image_filter_interlace on

品茶:渐进式jpeg没懂啥意思

image_filter_jpeg_quality quality; #quality:1-100

品茶:这个值控制图片的质量,影响清晰度

nginx.conf

-----------------------------------------------------------------

location ~* /image {

image_filter_jpeg_quality 20;

image_filter resize 500 500;

image_filter_buffer 10M;

image_filter_interlace on;

#image_filter rotate 20;

#image_filter crop 200 200;

#image_filter size;

#image_filter test;

}

------------------------------------------------------------------

152739265.jpg

152740771.jpg

152740419.jpg

152740163.jpg

品茶:这就是效果

image_filter_sharpen percent;

品茶:锐化比

image_filter_transparency on|off;

品茶:透明损失度

品茶:想了一下写几个规则,可能有用。

比如匹配全站所有的结尾图片

----------------------------------------------

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 ~* .*\.(jpg|gif|png)$ {

image_filter resize $width $height;

}

---------------------------------------------------

那么效果是:

170119901.jpg

170119528.jpg

170119385.jpg

170119425.jpg

品茶:是不是很cool,哈哈,更新完毕了。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/222f62cbf909b8795b7d1c44cf3b7473.html