change to PNG

This commit is contained in:
2022-08-22 23:59:02 +08:00
parent ae5a0c0337
commit 980fec142f
3 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ end
local file_to_check = string.match(ngx.var.request_uri, ".*/(.*)")
local file_dir = ngx.var.tmp_file_dir
local fullpath = file_dir .. "/" .. file_to_check .. ".jpeg";
local fullpath = file_dir .. "/" .. file_to_check .. ".png";
ngx.log(ngx.INFO, "FILE TO CHECK -> ", fullpath)
ngx.say(file_exists(fullpath))
+5 -3
View File
@@ -13,7 +13,7 @@ ngx.log(ngx.INFO, 'REQ_BODY -> ', ngx.req.get_body_data())
local data = req_body["payload"]["images"]
local combined_uuid = uuid.generate_v4()
local combined = file_dir .. "/" .. combined_uuid .. ".jpeg";
local combined = file_dir .. "/" .. combined_uuid .. ".png";
local len = table.getn(data)
if len == 0 then
@@ -24,7 +24,9 @@ end
local origin = {}
for i = 1, len do
ngx.log(ngx.INFO, "COMBINE FILE ->", data[i])
origin[i] = file_dir .. "/" .. data[i] .. " "
local cmd = convert .. " -resize 1280x " .. data[i] .. " " .. data[i] .. ".png"
ngx.log(ngx.INFO, 'CMD RESIZE -> ', cmd)
origin[i] = file_dir .. "/" .. data[i] .. ".png "
end
-- 从 nginx 变量取
local convert = ngx.var.convert
@@ -36,7 +38,7 @@ if not convert then
end
local cmd = convert .. " -append " .. table.concat(origin, " ") .. " " .. combined
ngx.log(ngx.INFO, 'CMD -> ', cmd)
ngx.log(ngx.INFO, 'CMD APPEND -> ', cmd)
io.popen(cmd)
ngx.say(combined_uuid)
+1 -1
View File
@@ -7,7 +7,7 @@ local file_to_upload = string.match(ngx.var.request_uri, ".*/(.*)")
ngx.log(ngx.INFO, 'UPLOAD COMBINED IMAGE -> file to upload -> ', file_to_upload)
local file_dir = ngx.var.tmp_file_dir
local fullpath = file_dir .. "/" .. file_to_upload .. ".jpeg";
local fullpath = file_dir .. "/" .. file_to_upload .. ".png";
ngx.log(ngx.INFO, 'UPLOAD COMBINED IMAGE -> fullpath -> ', fullpath)