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,15 +216,21 @@ local function get_stacks(images, encoding_variant)
if extra_image_extension and df.get_filetype(v.filename) == extra_image_extension then
is_extra = true
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)
if stacks[key] == nil then
stacks[key] = {}
end
if extra_image_content_type and (stacks[key]["sdr"] or is_extra) then
stacks[key][extra_image_content_type] = v
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
end
elseif not is_extra then
stacks[key]["sdr"] = v
-- Don't overwrite existing entries
if not stacks[key]["sdr"] then
stacks[key]["sdr"] = v
end
end
end
-- remove invalid stacks