-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path256_to_512.lua
67 lines (58 loc) · 1.38 KB
/
256_to_512.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
local filelist = assert(arg[1])
local output_dir = arg[2] or "."
local map = {}
-- init
for z = 0, 5 do
local tiles = 2 ^ (z + 1) - 1
map[z] = {}
for y = 0, tiles do
map[z][y] = {}
for x = 0, tiles do
map[z][y][x] = false
end
end
end
-- parse file list
for l in io.lines(filelist) do
for z, y, x in string.gmatch(l, "-(%d+)-(%d+)-(%d+)") do
z = tonumber(z)
y = tonumber(y)
x = tonumber(x)
map[z][y][x] = l
end
end
local magick4 = [[
echo %s
magick convert ^
( "%s" "%s" +append ) ^
( "%s" "%s" +append ) ^
-append ^
-quality 75 -define webp:lossless=false ^
"%s"
]]
local tile = "%s\\elex-%d-%d-%d.webp"
local _404 = "404.webp"
print("@echo off\n")
-- 512
for z = 0, 5 do
local tiles = 2 ^ (z + 1) - 1
for y = 0, tiles, 2 do
for x = 0, tiles, 2 do
local t1, t2, t3, t4
t1 = map[z][y+0][x+0]
t2 = map[z][y+0][x+1]
t3 = map[z][y+1][x+0]
t4 = map[z][y+1][x+1]
if t1 or t2 or t3 or t4 then
local out = tile:format(output_dir, z, y//2, x//2)
t1 = t1 or _404
t2 = t2 or _404
t3 = t3 or _404
t4 = t4 or _404
local cmd = magick4:format(out, t1, t2, t3, t4, out)
print(cmd)
end
end
end
print()
end