Files
dl/project/dl_console/res/批量清除图片透明色.lua
2026-09-16 14:07:40 +08:00

30 lines
746 B
Lua

local path_src = File.GetAbsolute("./src/")
local path_out = File.GetAbsolute("./out/")
-- 创建输出目录
File.DeleteContent(path_out)
File.CreateFolder(path_out)
local ret_files = File.GetPathFileAll(path_src, Img.REGEX_FORMAT, false)
for key, value in pairs(ret_files) do
local path = File.GetFilePath(value)
local filename = File.GetFileName(value)
local out = path_out .. string.lower(filename)
local img = Img.Create(value)
if img then
-- 参数为 透明度阈值、替换后颜色argb
Img.SetAlphaZero(img, 1, 4278255360)
Img.Save(img, out)
delete(img)
print(value.."->"..out)
end
end
print "此工具会将src文件夹的所有图片的透明颜色置0"
pause()