1.需要安装nginx
2.安装nginx http_image_filter_module 模块
3.上代码
server {
listen 80;
server_name 自己的图片网站域名;
# http://xxx.com/1.jpg
location / {
root 图片所在位置;
}
# http://xxx.com/1.jpg!100x100
location ~* /(.+)\.(jpg|gif|png)!(\d+)x(\d+)$ {
set $w $3;
set $h $4;
#这里一定要写
root 图片所在位置;
image_filter crop $w $h;
image_filter_buffer 10M;
try_files /$1.$2 /notfound.jpg;
}
}
开心一下:http://www.7gongju.cn