forked from DarkPhoenix911/Dawn-Pokemon-Showdown-Sprites
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tuprules.lua
53 lines (46 loc) · 1.54 KB
/
Tuprules.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
tup.include("util/strict.lua")
tup.include("util/lua-ext.lua")
tup.include("util/tup-ext.lua")
tup.include("util/sprites.lua")
ROOTDIR = tup.getcwd()
function pad(opts)
return rep{
"magick convert ${input} -background transparent -gravity center -extent ${w}x${h} ${output}",
input = opts.input or "%f",
output = opts.output or "%o",
w = opts.w,
h = opts.h
}
end
function trimimg(opts) -- Can't just be trim because of the string function...
return rep{
"magick convert ${input} -trim ${output}",
input = opts.input or "%f",
output = opts.output or "%o",
}
end
local function compressopts(program, copts)
copts.pngquant = getconfig(program .. "_PNGQUANT") or copts.pngquant
copts.optipng = getconfig(program .. "_OPTIPNG") or copts.optipng
copts.advpng = getconfig(program .. "_ADVPNG") or copts.advpng
end
function compresspng(opts)
local cmds = {}
local output = opts.output or "%o"
local copts = {}
compressopts("DEFAULT", copts)
if opts.config then
compressopts(opts.config, copts)
end
if copts.pngquant then
-- -f -o necessary to overwrite existing file
cmds += rep{"pngquant -f -o ${output} ${opts} ${output}", opts=copts.pngquant, output=output}
end
if copts.optipng then
cmds += rep{"optipng -q ${opts} ${output}", opts=copts.optipng, output=output}
end
if copts.advpng then
cmds += rep{"advpng -q ${opts} ${output}", opts=copts.advpng, output=output}
end
return cmds
end