Added Color_to_BW_Converter

This commit is contained in:
nitish-iiitd 2018-10-23 00:57:39 +05:30
parent 80c46d29d2
commit 640a146249
3 changed files with 28 additions and 0 deletions

View File

@ -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 <image_file_name>`
## Example
`$python bw_convert.py sample_image.jpg`

View File

@ -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")

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB