Code Monkey home page Code Monkey logo

Comments (5)

lmyJavaDE1 avatar lmyJavaDE1 commented on August 19, 2024

我也是这个问题,不知怎么解决?

from ngx_image_thumb.

oupula avatar oupula commented on August 19, 2024

注意nginx用户组是否有权限写入图片文件

nginx.conf 查看 user 是 哪个用户

from ngx_image_thumb.

yong472727322 avatar yong472727322 commented on August 19, 2024

例子:http://192.168.1.200:1234/group1/M00/00/04/wKgByFoL5JCAKs5CAAKTjdZqEq4291.jpg_500x400.jpg
server{
listen 1234;
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;
}

}

from ngx_image_thumb.

zhou7286 avatar zhou7286 commented on August 19, 2024

注意nginx用户组是否有权限写入图片文件

nginx.conf 查看 user 是 哪个用户

图片保存的位置呢?下次是不是直接使用?

from ngx_image_thumb.

oupula avatar oupula commented on August 19, 2024

注意nginx用户组是否有权限写入图片文件
nginx.conf 查看 user 是 哪个用户

图片保存的位置呢?下次是不是直接使用?

保存在图片原图目录,如果文件存在,肯定是直接使用的。
404的话,应该是文件权限问题,导致图片无法生成

from ngx_image_thumb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.