Skip to content

Commit

Permalink
buaazp: supported disable_zoom_up option for buaazp#72
Browse files Browse the repository at this point in the history
  • Loading branch information
buaazp committed Apr 30, 2015
1 parent 1d178c0 commit b001dc6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/conf/zimg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ admin_path = pwd .. '/www/admin.html'
disable_args = 0
--禁用lua脚本图片处理
disable_type = 0
--禁用图片放大
disable_zoom_up = 0
--lua process script
--lua脚本文件路径
script_name = pwd .. '/script/process.lua'
Expand Down
6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static void settings_init(void)
str_lcpy(settings.admin_path, "./www/admin.html", sizeof(settings.admin_path));
settings.disable_args = 0;
settings.disable_type = 0;
settings.disable_zoom_up = 0;
settings.script_on = 0;
settings.script_name[0] = '\0';
str_lcpy(settings.format, "none", sizeof(settings.format));
Expand Down Expand Up @@ -287,6 +288,11 @@ static int load_conf(const char *conf)
settings.disable_type = (int)lua_tonumber(L, -1);
lua_pop(L, 1);

lua_getglobal(L, "disable_zoom_up");
if(lua_isnumber(L, -1))
settings.disable_zoom_up = (int)lua_tonumber(L, -1);
lua_pop(L, 1);

lua_getglobal(L, "script_name"); //stack index: -1
if(lua_isstring(L, -1))
str_lcpy(settings.script_name, lua_tostring(L, -1), sizeof(settings.script_name));
Expand Down
1 change: 1 addition & 0 deletions src/zcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct setting{
char admin_path[512];
int disable_args;
int disable_type;
int disable_zoom_up;
int script_on;
char script_name[512];
char format[16];
Expand Down
6 changes: 6 additions & 0 deletions src/zscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ static int proportion(MagickWand *im, int p_type, int cols, int rows)
unsigned long im_cols = MagickGetImageWidth(im);
unsigned long im_rows = MagickGetImageHeight(im);

if (settings.disable_zoom_up == 1)
{
cols = cols > im_cols ? im_cols : cols;
rows = rows > im_rows ? im_rows : rows;
}

if (p_type == 1)
{
if (cols == 0 || rows == 0)
Expand Down

0 comments on commit b001dc6

Please sign in to comment.