add auto height or auto width mode and imgSize.php

This commit is contained in:
yanue
2016-01-14 14:32:02 +08:00
parent 265d781a76
commit 8a003fae22
8 changed files with 619 additions and 186 deletions

63
vhost/fdfs.conf Normal file
View File

@@ -0,0 +1,63 @@
server{
listen 80;
server_name fdfs.xxx.com;
set $img_thumbnail_root /opt/fastdfs/thumb; #set thumb path
set $img_file $img_thumbnail_root$uri; #thumb file
# like/pic/M00/xx/xx/xx.jpg_100-.jpg or /pic/M00/xx/xx/xx.jpg_-100.jpg
location ~* ^(\/(\w+)(\/M00)(.+\.(jpg|jpeg|gif|png)))_((\d+\-)|(\-\d+))\.(jpg|jpeg|gif|png)$ {
root $img_thumbnail_root; # root path for croped img
set $fdfs_group_root /opt/fastdfs/$2/store0/data; #set fastdfs group path $2
if (!-f $img_file) { # if thumb file not exists
add_header X-Powered-By 'Nginx+Lua+GraphicsMagick By Yanue'; # header for test
add_header file-path $request_filename; # header for test
set $request_filepath $fdfs_group_root$4; # origin_img full path/document_root/1.gif
set $img_size $6; # img width or height size depends on uri : img size like "-100" or "100-", "-" means auto size
set $img_ext $5; # file ext
content_by_lua_file /etc/nginx/lua/autoSize.lua; # load auto width or height crop Lua file
}
}
# like/pic/M00/xx/xx/xx.jpg_200x100.jpg
location ~* ^(\/(\w+)(\/M00)(.+\.(jpg|jpeg|gif|png))_(\d+)+x(\d+)+\.(jpg|jpeg|gif|png))$ {
root $img_thumbnail_root; # root path for croped img
set $fdfs_group_root /opt/fastdfs/$2/store0/data; #set fastdfs group path $2
if (!-f $img_file) { # if thumb file not exists
add_header X-Powered-By 'Nginx+Lua+GraphicsMagick By Yanue'; # header for test
add_header file-path $request_filename; # header for test
set $request_filepath $fdfs_group_root$4; # real file path
set $img_width $6; # img width
set $img_height $7; # img height
set $img_ext $5; # file ext
content_by_lua_file /etc/nginx/lua/cropSize.lua; # load crop Lua file
}
}
location /pic/M00 {
alias /opt/fastdfs/pic/store0/data;
ngx_fastdfs_module;
}
location /chat/M00 {
alias /opt/fastdfs/chat/store0/data;
ngx_fastdfs_module;
}
location /avatar/M00 {
alias /opt/fastdfs/avatar/store0/data;
ngx_fastdfs_module;
}
location /media/M00 {
alias /opt/fastdfs/media/store0/data;
ngx_fastdfs_module;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
}