diff --git a/Color_to_BW_Converter/README.md b/Color_to_BW_Converter/README.md new file mode 100644 index 0000000..4993e02 --- /dev/null +++ b/Color_to_BW_Converter/README.md @@ -0,0 +1,13 @@ +# Colored Image to Black & White Image Converter +A simple python script which takes colored image filename as argument and converts it into grayscale image and saves the output image file. It shows the basic usage of Pillow library. + +## Libraries Required +1. Pillow (PIL) +`$pip install Pillow` + +## Usage +1. Go to the script's folder and open command prompt. +2. Run command : `$python bw_convert.py ` + +## Example +`$python bw_convert.py sample_image.jpg` diff --git a/Color_to_BW_Converter/bw_convert.py b/Color_to_BW_Converter/bw_convert.py new file mode 100644 index 0000000..f79c9c3 --- /dev/null +++ b/Color_to_BW_Converter/bw_convert.py @@ -0,0 +1,15 @@ +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") diff --git a/Color_to_BW_Converter/sample_image.jpg b/Color_to_BW_Converter/sample_image.jpg new file mode 100644 index 0000000..1c0ccad Binary files /dev/null and b/Color_to_BW_Converter/sample_image.jpg differ