Skip to content

Instantly share code, notes, and snippets.

@Khalian
Created February 21, 2016 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Khalian/c9aee1d5a7f577908a0a to your computer and use it in GitHub Desktop.
Save Khalian/c9aee1d5a7f577908a0a to your computer and use it in GitHub Desktop.
A script to convert colored images to black and white
from PIL import Image
import sys
if (len(sys.argv) < 3):
print "Usage : python black_and_white.py inputFile outputFile"
sys.exit(0)
image_file = Image.open(sys.argv[1]) # open colour image
image_file = image_file.convert('1') # convert image to black and white
image_file.save(sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment