Don't overwrite existing stack slots (that way the first matching image in a stack will be used, vs the last one).

This commit is contained in:
Krzysztof Kotowicz
2024-09-20 11:38:24 +02:00
parent 2e95c4837b
commit 7e8340c526

View File

@@ -216,17 +216,23 @@ local function get_stacks(images, encoding_variant)
if extra_image_extension and df.get_filetype(v.filename) == extra_image_extension then if extra_image_extension and df.get_filetype(v.filename) == extra_image_extension then
is_extra = true is_extra = true
end end
-- we assume every image in the stack is generated from the same source image file -- We assume every image in the stack is generated from the same source image file
local key = df.chop_filetype(v.path .. PS .. v.filename) local key = df.chop_filetype(v.path .. PS .. v.filename)
if stacks[key] == nil then if stacks[key] == nil then
stacks[key] = {} stacks[key] = {}
end end
if extra_image_content_type and (stacks[key]["sdr"] or is_extra) then if extra_image_content_type and (is_extra or stacks[key]["sdr"]) then
-- Don't overwrite existing entries
if not stacks[key][extra_image_content_type] then
stacks[key][extra_image_content_type] = v stacks[key][extra_image_content_type] = v
end
elseif not is_extra then elseif not is_extra then
-- Don't overwrite existing entries
if not stacks[key]["sdr"] then
stacks[key]["sdr"] = v stacks[key]["sdr"] = v
end end
end end
end
-- remove invalid stacks -- remove invalid stacks
local count = 0 local count = 0
for k, v in pairs(stacks) do for k, v in pairs(stacks) do