-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPillow_Library.py
More file actions
62 lines (46 loc) · 1.58 KB
/
Pillow_Library.py
File metadata and controls
62 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
''' Install pillow library
change the image extension
resize image files
resize multiple images using for loop
Sharpness -----|
Brightness |
Color |------> import ImageEnhance module
Contrast -----|
Image blur, GaussianBlur ------> import ImageFilter module'''
from PIL import Image, ImageEnhance, ImageFilter
import os
# making instance of image
# img1 = Image.open('nik.jpg')
# creating new file with different extension
# img1.save('nik1.png')
# showing file
# img1.show('nik.jpg')
# resizing file
# MAX_SIZE = (250,250)
# img1.thumbnail(MAX_SIZE)
# img1.save('dognew.jpg')
# resizing multiple image at time using loop
# for item in os.listdir():
# if item.endswith('.jpg'):
# img1 = Image.open(item)
# filename,extension = os.path.splitext(item)
# img1.save(f'{filename}.png')
# Sharpness = ImageEnhance.Sharpness()
# img1 = Image.open('dog.jpg')
# enhancer = ImageEnhance.Sharpness(img1)
# enhancer.enhance(4).save('dogsharpness.jpg')
# Color = ImageEnhance.Color()
# img1 = Image.open('dog.jpg')
# enhancer = ImageEnhance.Color(img1)
# enhancer.enhance(3).save('dogcolor.jpg')
# Brightness = ImageEnhance.Brightness()
# img1 = Image.open('dog.jpg')
# enhancer = ImageEnhance.Brightness(img1)
# enhancer.enhance(2).save('dogbright.jpg')
# Contrast = ImageEnhance.Cntrast()
# img1 = Image.open('dog.jpg')
# enhancer = ImageEnhance.Contrast(img1)
# enhancer.enhance(2).save('dogcontrast.jpg')
# Blur
# img1 = Image.open('dog.jpg')
# img1.filter(ImageFilter.GaussianBlur(radius=2)).save('dogblur.jpg')