Add grayscale.py.

This commit is contained in:
voussoir 2020-06-17 13:43:25 -07:00
parent 8ea4a0e283
commit 43fd39eb3e

21
grayscale.py Normal file
View file

@ -0,0 +1,21 @@
import PIL.Image
import sys
from voussoirkit import pathclass
from voussoirkit import pipeable
from voussoirkit import winglob
def main(argv):
for pattern in pipeable.go(argv, strip=True, skip_blank=True):
filenames = winglob.glob(pattern)
for filename in filenames:
filename = pathclass.Path(filename)
if filename.replace_extension('').basename.endswith('_gray'):
continue
new_filename = filename.replace_extension('').absolute_path + '_gray' + filename.dot_extension
print(f'{filename.basename} -> {new_filename.basename}')
image = PIL.Image.open(filename.absolute_path).convert('LA')
image.save(new_filename)
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))