46 lines
1.3 KiB
Lua
46 lines
1.3 KiB
Lua
local path_src = File.GetAbsolute("./src/")
|
|
local path_out = File.GetAbsolute("./out/")
|
|
local scale = 0.5
|
|
|
|
-- 创建输出目录
|
|
File.CreateFolder(path_out)
|
|
|
|
local ret_files = File.GetPathFileAll(path_src, Img.REGEX_FORMAT, false)
|
|
|
|
for key, value in pairs(ret_files) do
|
|
--
|
|
local img = Img.Create(value)
|
|
local out = path_out .. File.GetRelative(value, path_src)
|
|
out = String.ReplaceExtension(out, "png")
|
|
|
|
local img_out = Img.Resize(img, scale)
|
|
delete(img)
|
|
Img.Save(img_out, out)
|
|
delete(img_out)
|
|
|
|
-- 锚点文件处理
|
|
local mata_name = String.EraseFilename(value)
|
|
mata_name = mata_name .. "Placements/".. String.GetFileStem(value) .. ".txt"
|
|
local out_name = String.EraseFilename(out)
|
|
File.CreateFolder(out_name .. "Placements/")
|
|
out_name = out_name .. "Placements/".. String.GetFileStem(value) .. ".txt"
|
|
|
|
|
|
local str = File.GetString(mata_name)
|
|
if #str > 0 then
|
|
print(str)
|
|
local pos = String.toPosition2(str, '\n')
|
|
pos.y = math.floor(pos.y * scale)
|
|
print(pos.y)
|
|
pos.y = math.floor(pos.y * scale)
|
|
str = pos.x..'\n'..pos.y
|
|
|
|
File.SaveString(str, out_name)
|
|
end
|
|
|
|
print(value .. "->" .. out)
|
|
end
|
|
|
|
print "此工具会批量缩放src文件夹的所有图片,若只是统一转换为png,则scale填1"
|
|
|
|
pause() |