Update to_png.py
Default > delete bmp
This commit is contained in:
@@ -10,7 +10,7 @@ pixel to fully transparent, and writes a PNG.
|
|||||||
Usage:
|
Usage:
|
||||||
python3 to_png.py [dir ...] # default: all gfx*_extracted dirs
|
python3 to_png.py [dir ...] # default: all gfx*_extracted dirs
|
||||||
python3 to_png.py --key RRGGBB ... # custom colorkey (hex), default 000000
|
python3 to_png.py --key RRGGBB ... # custom colorkey (hex), default 000000
|
||||||
python3 to_png.py --keep # keep .bmp files (default keeps them)
|
python3 to_png.py --keep # keep .bmp files (default deletes them)
|
||||||
"""
|
"""
|
||||||
import sys, os, glob
|
import sys, os, glob
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -30,6 +30,7 @@ def convert(path, key):
|
|||||||
def main():
|
def main():
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
key = (0, 0, 0)
|
key = (0, 0, 0)
|
||||||
|
keep = False
|
||||||
dirs = []
|
dirs = []
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(args):
|
while i < len(args):
|
||||||
@@ -37,6 +38,8 @@ def main():
|
|||||||
h = args[i+1].lstrip('#')
|
h = args[i+1].lstrip('#')
|
||||||
key = (int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16))
|
key = (int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16))
|
||||||
i += 2
|
i += 2
|
||||||
|
elif args[i] == '--keep':
|
||||||
|
keep = True; i += 1
|
||||||
else:
|
else:
|
||||||
dirs.append(args[i]); i += 1
|
dirs.append(args[i]); i += 1
|
||||||
if not dirs:
|
if not dirs:
|
||||||
@@ -47,6 +50,8 @@ def main():
|
|||||||
for b in bmps:
|
for b in bmps:
|
||||||
try:
|
try:
|
||||||
convert(b, key)
|
convert(b, key)
|
||||||
|
if not keep:
|
||||||
|
os.remove(b)
|
||||||
total += 1
|
total += 1
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(' ERROR %s: %s' % (b, ex))
|
print(' ERROR %s: %s' % (b, ex))
|
||||||
|
|||||||
Reference in New Issue
Block a user