lyd2004888 发表于 2017-12-23 23:22:03

Nginx笔记总结十七:nginx生成缩略图配置(http

  编译:
  ./configure --prefix=/usr/local/nginx
  --with-http_stub_status_module --with-http_realip_module
  --with-http_image_filter_module --with-debug
  配置:
  

location ~* /(\d+).(jpg)$ {  
  set $h $arg_h;
  
  set $
w $arg_w;  
  image_filter resize $h $
w;  
}
  
location
~* /(\d+)_(\d+)x(\d+)\.(jpg)$ {  
  
if ( -e $document_root/$1.$4) {  
    rewrite
/(\d+)_(\d+)x(\d+)\.(jpg)$ /$1.$4?h=$2&w=$3 last;  
  }
  
  return
404;  
}
  

  参数:test 返回是否真的是图片

  >  corp:截取图片的一部分,从左上角开始截取
  resize:缩放图片,等比例缩放
  优点:根据传入参数即可生成各种比例图片
  不占用任何磁盘空间
  缺点:消耗cpu,访问量大会给服务器带来极大的负担
页: [1]
查看完整版本: Nginx笔记总结十七:nginx生成缩略图配置(http