Last active
March 12, 2020 10:56
-
-
Save namieluss/bfe8b7f80ff457926bded7b44d985fdc to your computer and use it in GitHub Desktop.
Convert Image to Grayscale (black and white)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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