Skip to content

Instantly share code, notes, and snippets.

@namieluss
Last active March 12, 2020 10:56
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 namieluss/bfe8b7f80ff457926bded7b44d985fdc to your computer and use it in GitHub Desktop.
Save namieluss/bfe8b7f80ff457926bded7b44d985fdc to your computer and use it in GitHub Desktop.
Convert Image to Grayscale (black and white)
from PIL import Image
# open colour image
img = Image.open("test_image.jpg")
# convert image to black and white
img = img.convert("1")
# save new image
img.save("test_image_grayscale.jpg")
# show image in preview
img.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment