diff --git a/prod/upload/combine.lua b/prod/upload/combine.lua index 96353d2..feb50e6 100644 --- a/prod/upload/combine.lua +++ b/prod/upload/combine.lua @@ -13,20 +13,24 @@ local origin = {} for i = 1, len do origin[i] = file_dir .. "/" .. data[i] .. " " end --- in linux +-- linux local magick = "/usr/local/ImageMagick/bin/magick" local tmp = io.open(magick,"r") if tmp == nil then - -- in mac os + -- mac os magick = "/usr/local/bin/magick" else io.close(tmp) end -local file = io.popen(magick .. " convert -append " .. table.concat(origin, " ") .. " " .. combined) -file:read("*all") -file:close() -file = io.open(combined) -local content = file:read("*all") -file:close() -os.remove(combined) -ngx.say(content) \ No newline at end of file + +local result, _, code = os.execute(magick .. " convert -append " .. table.concat(origin, " ") .. " " .. combined) +if result and code == 0 then + local file = io.open(combined) + local content = file:read("*all") + file:close() + os.remove(combined) + ngx.say(content) +else + ngx.status = 500 + ngx.say("image combine failed.") +end \ No newline at end of file