Add grayscale.py.
This commit is contained in:
parent
8ea4a0e283
commit
43fd39eb3e
1 changed files with 21 additions and 0 deletions
21
grayscale.py
Normal file
21
grayscale.py
Normal 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:]))
|
Loading…
Reference in a new issue