nginx-image-filter配置实现缩略图

查看模块是否安装

/usr/local/nginx/sbin/nginx -V

表示已安装

nginx配置

server {
	listen 80;
	server_name 127.0.0.1; #域名或IP
	root /root/data; #图片目录
	#实现图片缩略图
	location ~ (.+)\.(jpg|gif|png|JPG|JPEG|PNG|GIF)@(\d+)w_(\d+)h_(\d+)Q_([rc])$ {		 
		set $w $3; #宽
		set $h $4; #高
		set $q $5; #图片质量
		set $type $6;
		set $image_path  $1.$2; #真实图片地址
		set $cache_path  $1_$3w_$4h_$5Q_$6.$2;  #临时文件地址
		
		if ($type = 'r') {
			set $type 'image-resize';
		}
		if ($type = 'c') {
			set $type 'image-crop';
		}
		set $image_uri /$type$image_path?w=$w&h=$h&q=$q;	
		if (-f $cache_path) {
			rewrite (.+)\.(jpg|gif|png|JPG|JPEG|PNG|GIF)@(\d+)w_(\d+)h_(\d+)Q_([rc])$ $1_$3w_$4h_$5Q_$6.$2;
			break;
		}
		if (!-f $cache_path) {	
			pro
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值