Code Monkey home page Code Monkey logo

ngx_image_thumb's Issues

代码中存在gd函数内存泄露

在make_thumb函数中,562行。
需要在562行之前,添加一个语句"gdImageDestroy(info->dst_im);",用来释放make_thumb函数开始的地方分配的内存。

配置后,404,未找到图片

2014/02/28 04:04:45 [error] 23284#0: *1 open() "/data0/knose/ppwork/uploads/1_45_65.jpg!c300x200.jpg" failed (2: No such file or directory), client: 192.168.0.117, server: localhost, request: "GET /ppwork/uploads/1_45_65.jpg!c300x200.jpg HTTP/1.1", host: "192.168.0.5:6001"

配置文件
location /uploads {
root /data0/knose;
image on;
image_output on;
}

请求新特性

1:能够设置图片压缩大小格式,例如:20x20,100x100,防止随意生成不同格式图片。
2:图片可能存储fastdfs中,nginx通过http请求下载图片到本地,在压缩,添加水印。
3:可以缓存压缩图片,如果已经压缩过,还重复压缩吗?
我以前通过nginx+lua方式做过:http://www.iteye.com/topic/1125126

make errors

when I make ,it report this errors
/Users/renshangui/.nginx/ngx_image_thumb/ngx_http_image_module.c:767:30: error:
array index 6 is past the end of the array (which contains 6 elements)
[-Werror,-Warray-bounds]
strcat(info->source_file,buffer[6]);
^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/secure/_string.h:125:33: note:
expanded from macro 'strcat'
__builtin___strcat_chk (dest, src, __darwin_obsz (dest))
^
/Users/renshangui/.nginx/ngx_image_thumb/ngx_http_image_module.c:722:5: note:
array 'buffer' declared here
char buffer[6][255];
^
/Users/renshangui/.nginx/ngx_image_thumb/ngx_http_image_module.c:771:35: error:
array index 6 is past the end of the array (which contains 6 elements)
[-Werror,-Warray-bounds]
strcat(info->request_filename,buffer[6]);
^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/secure/_string.h:125:33: note:
expanded from macro 'strcat'
__builtin___strcat_chk (dest, src, __darwin_obsz (dest))
^
/Users/renshangui/.nginx/ngx_image_thumb/ngx_http_image_module.c:722:5: note:
array 'buffer' declared here
char buffer[6][255];
^
2 errors generated.
make[1]: *** [objs/addon/ngx_image_thumb/ngx_http_image_module.o] Error 1
make: *** [build] Error 2

libgd.so.2 error

GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /opt/local/nginx/sbin/nginx...done.
[New LWP 168]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `nginx: worker process '.
Program terminated with signal 11, Segmentation fault.
#0 0x00007ff2a862a167 in gdImageDestroy () from /lib64/libgd.so.2
Missing separate debuginfos, use: debuginfo-install cyrus-sasl-lib-2.1.26-20.el7_2.x86_64 expat-2.1.0-10.el7_3.x86_64 fontconfig-2.10.95-10.el7.x86_64 freetype-2.4.11-12.el7.x86_64 gd-2.0.35-26.el7.x86_64 glibc-2.17-157.el7_3.1.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.14.1-27.el7_3.x86_64 libX11-1.6.3-3.el7.x86_64 libXau-1.0.8-2.1.el7.x86_64 libXpm-3.5.11-3.el7.x86_64 libcom_err-1.42.9-9.el7.x86_64 libcurl-7.29.0-35.el7.centos.x86_64 libidn-1.28-4.el7.x86_64 libjpeg-turbo-1.2.90-5.el7.x86_64 libpng-1.5.13-7.el7_2.x86_64 libselinux-2.5-6.el7.x86_64 libssh2-1.4.3-10.el7_2.1.x86_64 libxcb-1.11-4.el7.x86_64 nspr-4.11.0-1.el7_2.x86_64 nss-3.21.0-9.el7_2.x86_64 nss-softokn-freebl-3.16.2.3-14.2.el7_2.x86_64 nss-util-3.21.0-2.2.el7_2.x86_64 openldap-2.4.40-9.el7_2.x86_64 openssl-libs-1.0.1e-60.el7_3.1.x86_64 pcre-8.32-15.el7_2.1.x86_64 zlib-1.2.7-17.el7.x86_64
(gdb) bt
#0 0x00007ff2a862a167 in gdImageDestroy () from /lib64/libgd.so.2
#1 0x00000000004a685a in calc_image_info (conf=0x1cb6428) at ngx_image_thumb-master/ngx_http_image_module.c:1057
#2 parse_image_info (conf=0x1cb6428) at ngx_image_thumb-master/ngx_http_image_module.c:934
#3 ngx_http_image_handler (r=0x1cc65d0) at ngx_image_thumb-master/ngx_http_image_module.c:442
#4 0x0000000000448592 in ngx_http_core_content_phase (r=0x1cc65d0, ph=) at src/http/ngx_http_core_module.c:1515
#5 0x00000000004429d3 in ngx_http_core_run_phases (r=r@entry=0x1cc65d0) at src/http/ngx_http_core_module.c:934
#6 0x0000000000442aed in ngx_http_handler (r=r@entry=0x1cc65d0) at src/http/ngx_http_core_module.c:917
#7 0x000000000044f09f in ngx_http_process_request (r=r@entry=0x1cc65d0) at src/http/ngx_http_request.c:1930
#8 0x000000000044f493 in ngx_http_process_request_headers (rev=rev@entry=0x7ff2a231f0e0) at src/http/ngx_http_request.c:1360
#9 0x000000000044f7bc in ngx_http_process_request_line (rev=rev@entry=0x7ff2a231f0e0) at src/http/ngx_http_request.c:1031
#10 0x000000000044fbe9 in ngx_http_wait_request_handler (rev=0x7ff2a231f0e0) at src/http/ngx_http_request.c:500
#11 0x000000000042bee1 in ngx_event_process_posted (cycle=cycle@entry=0x1ca2b70, posted=0x704c10 <ngx_posted_events>) at src/event/ngx_event_posted.c:33
#12 0x000000000042b9cb in ngx_process_events_and_timers (cycle=cycle@entry=0x1ca2b70) at src/event/ngx_event.c:278
#13 0x0000000000433c17 in ngx_worker_process_cycle (cycle=0x1ca2b70, data=) at src/os/unix/ngx_process_cycle.c:862
#14 0x000000000043104c in ngx_spawn_process (cycle=cycle@entry=0x1ca2b70, proc=proc@entry=0x433b1c <ngx_worker_process_cycle>, data=data@entry=0x0,
name=name@entry=0x4ac44e "worker process", respawn=respawn@entry=-4) at src/os/unix/ngx_process.c:198
#15 0x0000000000432d3e in ngx_start_worker_processes (cycle=cycle@entry=0x1ca2b70, n=4, type=type@entry=-4) at src/os/unix/ngx_process_cycle.c:385
#16 0x0000000000434cfe in ngx_master_process_cycle (cycle=cycle@entry=0x1ca2b70) at src/os/unix/ngx_process_cycle.c:260
#17 0x000000000041284e in main (argc=, argv=) at src/core/nginx.c:437
(gdb)

./configure: error: no ./nginx-image-master/config was found

Tengine 2.1.2

./configure --add-module=./nginx-image-master

编译报错

[root@test1 tengine-2.1.2]# ll ./ngx_image_thumb-master/
total 64
-rw-r--r-- 1 root root 704 Aug 17 12:07 config
-rw-r--r-- 1 root root 41871 Aug 17 12:07 ngx_http_image_module.c
-rw-r--r-- 1 root root 4795 Aug 17 12:07 README_EN.md
-rw-r--r-- 1 root root 5013 Aug 17 12:07 README.md

不支持bmp图片文件,不支持的文件打开后没有关闭

static int get_ext_header(char *filename)
{
FILE *handle;
handle = fopen(filename, "rb");
int ret = NGX_IMAGE_NONE; //添加处理,访问格式不存在时关闭打开的文件

if(!handle) {
    return NGX_IMAGE_NONE;
} else {
    unsigned short filetype;//bmp 0x4D42
    if(fread(&filetype, sizeof(unsigned short), 1, handle)) {
        if( filetype == 0xD8FF) {
            ret = NGX_IMAGE_JPEG;
        } else if( filetype == 0x4947) {
            ret = NGX_IMAGE_GIF;
        } else if( filetype == 0x5089) {
            ret = NGX_IMAGE_PNG;
        } else if ( filetype == 0x4d42) {
            ret = NGX_IMAGE_BMP; //添加处理bmp格式
        }

#if 0
else {
ret = NGX_IMAGE_NONE;
}
#endif
}
}
fclose(handle);
return ret;
}

访问 404 是啥原因? config 有问题吗? 版本号 nginx-1.12

server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/default;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;
		
	location / {
		   
		   image on;
		   image_output on;
	}

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }
}

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.