Skip to content

Commit a972229

Browse files
authored
Merge pull request #137 from DevyDhanish/newbranch
Added a horror photo converter
2 parents 91de897 + b6ac775 commit a972229

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# put all the photo in "phototouse" folder run the script . Done your photo will be in "photoout" folder
2+
3+
from PIL import Image, ImageEnhance, ImageOps
4+
import os
5+
6+
path = r"phototouse"
7+
out = r"photoout"
8+
9+
factor = 2
10+
brightness = 1.5
11+
12+
def edit_photo(filepath):
13+
editedimg = Image.open(filepath)
14+
editedimg = editedimg.convert("L")
15+
editedimg = ImageEnhance.Contrast(editedimg).enhance(factor)
16+
editedimg = ImageEnhance.Brightness(editedimg).enhance(brightness)
17+
editedimg = ImageOps.expand(editedimg, border=20, fill=10)
18+
return editedimg
19+
20+
for filename in os.listdir(path):
21+
#!Get photo path
22+
filepath = (f"{path}\{filename}")
23+
print(filepath)
24+
25+
#!edit the photo
26+
editPic = edit_photo(filepath)
27+
28+
#!Save the photo
29+
editPic.save(f"{out}\{os.path.splitext(filename)[0]}_edited.jpg")
30+
31+
print("DONE ✅")
21.4 KB
Loading
26.3 KB
Loading

0 commit comments

Comments
 (0)