Skip to content

Commit 98b4a25

Browse files
authored
Create Crop_An_Image,py
1 parent 8835a7f commit 98b4a25

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Crop_An_Image,py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from PIL import Image
2+
3+
# Opens a image in RGB mode
4+
orginal = Image.open(r"C:\Users\Belgin\Pictures\github.png")
5+
6+
# Size of the image in pixels (size of orginal image)
7+
width, height = orginal.size
8+
9+
# Setting the points for cropped image
10+
left = 5
11+
top = height / 4
12+
right = 164
13+
bottom = 3 * height / 4
14+
15+
# Cropped image of above dimension
16+
# (It will not change orginal image)
17+
cropped_image = orginal.crop((left, top, right, bottom))
18+
19+
# Shows the image in image viewer
20+
cropped_image.show()

0 commit comments

Comments
 (0)