使用nginx_image_filter生成缩略图并保存在服务器上
2017-11-28 14:43
2071 查看
例子:http://192.168.1.200:12345/group1/M00/00/04/wKgByFoL5JCAKs5CAAKTjdZqEq4291.jpg_500x400.jpg
server{
######使用nginx_image_filter生成缩略图并保存在服务器上
}
server{
listen 12345; client_max_body_size 100m; #########使用nginx_image_filter生成缩略图并保存在服务器上############################ #第一步:访问缩略图 location ~ '^/group1/M00/([0-9A-F]{2})/([0-9A-F]{2})/(.*)\.(jpg|jpeg|png)_([\d]+)x([\d]+)\.(jpg|jpeg|png)$' { #直接从缩略图所在目录查找 root /home/fastdfs/cache/; #如果缩略图不存在,转到生成缩略图的location if (!-f $request_filename) { #记录变量 set $width $5; set $height $6; set $image_path $1/$2; set $image_name $3.$4; #把缩略图的尺寸放入请求参数中 set $image_uri thumb_image/$image_path/$image_name?width=$width&height=$height; proxy_pass http://127.0.0.1:$server_port/$image_uri; } #如果缩略图存在,则直接break,因为缓存缩略图的配置只能写在location的根下 if (-f $request_filename) { break; } #缓存缩略图 #缩略图保存目录 proxy_store /$request_filename; proxy_store_access user:rw group:rw all:rw; proxy_temp_path /home/fastdfs/cache_temp/; proxy_set_header Host $host; proxy_set_header Content-Type image/jpeg; } #第二步:生成缩略图 location /thumb_image { #原图目录 alias /home/fastdfs/data/; image_filter resize $arg_width $arg_height; image_filter_jpeg_quality 25; # 压缩质量 image_filter_buffer 20m; # 如果原始图片大小起过1m,则会报415错误 #不允许外部访问 allow 127.0.0.0/8; deny all; }
######使用nginx_image_filter生成缩略图并保存在服务器上
#访问原图:匹配FastDFS,不需要缩略图的,直接使用FastDFS即可 location ~*^/group1/M00/.*\.(jpg|jpeg|png)$ { ngx_fastdfs_module; }
}
相关文章推荐
- nginx使用image_filter生成缩略图 -- fasdfs海量图片缩略图整合
- 解决nginx利用image_filter动态生成缩略图不支持bmp
- nginx利用image_filter动态生成缩略图
- nginx利用image_filter动态生成缩略图
- nginx使用image_filter模块配置图片缩略图
- nginx利用image_filter动态生成缩略图
- echarts 生成统计图时,自动保存图片到服务器,并使用freemarker生成word
- [Nginx]使用nginx的image_filter_module来处理图片
- 使用ASP.NET Image Generation生成图片缩略图及水印
- nginx+fastdfs+image_filter 实现实时缩略图
- laravel 使用Intervention/image生成缩略图
- nginx缩略图image_filter配置整合fastdfs
- 使用ASP.NET Image Generation生成图片缩略图及水印
- Nginx的 http_image_filter_module 模块使用说明
- 使用nginx作为css,js,image静态文件的服务器
- 使用POI生成Excel并进行流下载(不需在服务器上保存)
- nginx 动态缩略图模块安装(ngx_http_image_filter_module)
- echarts 生成统计图时,自动保存图片到服务器,并使用freemarker生成word
- Nginx之http_image_filter_module模块使用
- Nginx之http_image_filter_module模块使用