modify README.md
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
local uuid = require "resty.jit-uuid"
|
||||
local cjson = require "cjson"
|
||||
|
||||
local json_string = nil
|
||||
|
||||
---- Automatic seeding with os.time(), LuaSocket, or ngx.time()
|
||||
uuid.seed()
|
||||
uuid()
|
||||
|
||||
-- Get post json argv
|
||||
local arg = ngx.req.get_post_args()
|
||||
for k,v in pairs(arg) do
|
||||
ngx.log(ngx.INFO , "Image append [POST] key:", k .." | ".." v:", v)
|
||||
json_string = v
|
||||
end
|
||||
|
||||
-- Decode json string
|
||||
local json = cjson.decode(json_string)
|
||||
ngx.say("Image append input filename number is :" , table.getn(json.data))
|
||||
local image_append_input_files_number = table.getn(json.data)
|
||||
for i = 1, image_append_input_files_number do
|
||||
ngx.log(ngx.INFO , "Image append input filename is :" , json.data[i])
|
||||
end
|
||||
|
||||
-- Image append
|
||||
---- Upload file save path config in nginx.conf
|
||||
local save_upload_file_path = ngx.var.store_dir
|
||||
local append_image_table = {}
|
||||
local output_image_uuid = uuid.generate_v4();
|
||||
|
||||
-- Add path to input image filename
|
||||
for i = 1, image_append_input_files_number do
|
||||
append_image_table[i] = save_upload_file_path .. json.data[i] .. " "
|
||||
ngx.log(ngx.INFO, "Insert append image table "..i.." with "..append_image_table[i])
|
||||
end
|
||||
|
||||
-- Concat input image to a command string
|
||||
local append_input_images = table.concat(append_image_table)
|
||||
ngx.log(ngx.INFO , "Input images list : " , append_input_images)
|
||||
|
||||
-- Add path to output image filename
|
||||
local append_output_image = save_upload_file_path .. output_image_uuid..".jpg ";
|
||||
ngx.log(ngx.INFO , "Output image is : "..append_output_image)
|
||||
|
||||
-- Debug
|
||||
ngx.log(ngx.INFO , '/usr/local/ImageMagick/bin/magick convert -append '..append_input_images..' '..append_output_image)
|
||||
|
||||
local call_imagemagick_cmd = io.popen('/usr/local/ImageMagick/bin/magick convert -append '..append_input_images..' '..append_output_image)
|
||||
local imagemagick_cmd_replay = call_imagemagick_cmd:read("*all")
|
||||
ngx.log(ngx.INFO , imagemagick_cmd_replay)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user