超简单的Python黑白转换程序,调用如下:
python.exe bwtrans.py "<source-path>" "<destination-path>"
记得安装pillow模块哦~
保存以下代码为bwtrans.py即可!
import sys
from PIL import Image
script, src, dst = sys.argv
im = Image.open(src)
for x in range(im.size[0]):
for y in range(im.size[1]):
pix = im.getpixel((x, y))
m = int(sum(pix) / 3)
im.putpixel((x, y), (m, m, m))
im.save(dst)