Skip to content

Instantly share code, notes, and snippets.

@harendra21
Created May 11, 2022 05:48
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 harendra21/9325fcb4aa797338163dd424ee2e2d9d to your computer and use it in GitHub Desktop.
Save harendra21/9325fcb4aa797338163dd424ee2e2d9d to your computer and use it in GitHub Desktop.
import sys
from PIL import Image
from PIL.ExifTags import TAGS
image_file = sys.argv[1]
image_name = image_file.split(".")[0]
try:
image = Image.open(image_file)
except IOError:
print("Error in loading image!!")
sys.exit(1)
bw_image = image.convert('L')
bw_image.save("bw_"+image_name+".png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment