< Previous | Contents | Next >
This example updates metadata fields
function Process(req)
local f_name = InFieldName:GetValue(req).Value local f_value = InFieldValue:GetValue(req).Value local img = InImage:GetValue(req)
local result = Image({IMG_Like = img, IMG_NoData = req:IsPreCalc()}) img:Crop(result, { })
if (f_name ~= "") then
local newmetadata = result.Metadata or {} if f_value ~= "" then
-- create subtables for dotted field names local key
local subtable = newmetadata
for key in string.gmatch(f_name, "([%w_]+)%.") do subtable[key] = subtable[key] or {} subtable = subtable[key]
end
-- get final key
f_name = string.match(f_name, "[%w_]+$")
-- look for tables in f_value
local tbl = string.match(f_value, "%s*%b{}%s*") if tbl then
subtable[f_name] = eyeon.readstring(f_value) -- parse tables
else
subtable[f_name] = f_value
end
else
newmetadata[f_name] = nil
end
result.Metadata = newmetadata
end
OutImage:Set(req, result)
end