富贵资源网 Design By www.hznty.com

Nginx的ngx_http_image_filter_module 模块(nginx版本为0.7.54+) 可用来动态转换JPEG, GIF, PNG, 和WebP格式的图片大小。

该模块默认没有构建,需要通过 --with-http_image_filter_module 配置参数启用。

如果图片访问量不大,可以使用该模块。

该模块使用了libgd库。 推荐使用该库的最新版本。

以下为在已经安装了nginx的情况下添加该模块的步骤。

1 安装依赖

yum -y install gd-devel
yum -y install libxslt-devel
yum -y install perl-devel perl-ExtUtils-Embed

2 查看原nginx参数

"htmlcode">
./configure --with-http_image_filter_module=dynamic
make

4 备份原nginx

cp -r /usr/local/nginx /usr/local/nginxbak

5 覆盖nginx

cp objs/nginx /usr/local/nginx/sbin/
mkdir /usr/local/nginx/module
cp objs/ngx_http_image_filter_module.so /usr/local/nginx/module/ngx_http_image_filter_module.so

6 修改配置文件

vim /usr/local/nginx/conf/nginx.conf

load_module /usr/local/nginx/module/ngx_http_image_filter_module.so;
location ~* /images/(.+)_(\d+)x(\d+)\.(jpg|jpeg|gif|png)$ {
        set $w $2;
        set $h $3;
        image_filter resize $w $h;
        image_filter_buffer 30M; #设置图片缓冲区的最大大小,大小超过设定值,服务器将返回错误415
        image_filter_interlace on;
        image_filter_jpeg_quality 80;
        try_files /$1.$4 /notfound.jpg;
        expires 1d;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        alias /home/publisherupload/ ; #root 能够让访问 /images/ 路径时,访问到 /User/XX/Desktop/images,如果将 root 替换为 alias,则访问的是 /User/XX/Desktop/;其中 /User/XX/Desktop/ 是本机中的绝对路径。
    }

location /images {
  alias /home/publisherupload/ ; #root 能够让访问 /images/ 路径时,访问到 /User/XX/Desktop/images,如果将 root 替换为 alias,则访问的是 /User/XX/Desktop/;其中 /User/XX/Desktop/ 是本机中的绝对路径。
  autoindex on; #打开目录浏览功能
}

7 重载nginx配置

/usr/local/nginx/sbin/nginx -s

8 测试

最终的图片访问地址为在原图片地址后面加入_宽度X高度参数

http://110.87.103.58:12345/images/2021-01/202101250944272_500x400.png

参考

https://cloud.tencent.com/developer/article/1644466

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。