Skip to content

Commit 24ae7cb

Browse files
committed
Image GrayScalling Utility added V_1
1 parent 65d6ee0 commit 24ae7cb

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed
1.54 MB
Loading

Image Grayscalling/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Compress Image
2+
3+
## Description
4+
This snippet of code will convert any image to grayscale.
5+
6+
## Requirements
7+
8+
`$ pip install Pillow`
9+
10+
## Steps To Execution
11+
- Fork this repo and navigate to ShortenLinks folder
12+
- (optional) Add images to same directory with this `code.py` file.
13+
- Modify the image name in `code.py`GrayScaled_YOURIMGNAME.jpg".
14+
15+
## Output
16+
17+
18+
| Before | After |
19+
|:---:|:---------------------------------------------------------------------------------------------------------------------:|
20+
| ![1](https://user-images.githubusercontent.com/52918207/121647416-0151e380-cab4-11eb-96d1-1dfd127789c6.jpg) | ![1_compressed](https://user-images.githubusercontent.com/52918207/121647438-06af2e00-cab4-11eb-9fa5-b84787163bb2.jpg) |
21+
| Colourful | GrayScaled |
22+

Image Grayscalling/code.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from PIL import Image
2+
from os import listdir,getcwd
3+
from os.path import isfile, join
4+
5+
onlyfiles = [f for f in listdir(getcwd()) if isfile(join(getcwd(), f))]
6+
print("All files in current dir :",onlyfiles)
7+
8+
img = Image.open(input("Enter image filename : ")) # image name with relative path
9+
grayscale = img.convert('L')
10+
grayscale.save('GrayScaled_{}'.format(img.filename))
11+

Image Grayscalling/demo.jpg

1.67 MB
Loading

0 commit comments

Comments
 (0)