Skip to content

Commit 9814a20

Browse files
committed
Compress Image Utility Added
1 parent db09d11 commit 9814a20

File tree

5 files changed

+5
-10
lines changed

5 files changed

+5
-10
lines changed

Compress Image/1.jpg

6.95 MB
Loading

Compress Image/1_compressed.jpg

1.67 MB
Loading

Compress Image/README.md

Whitespace-only changes.

Compress Image/code.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import PIL
21
from PIL import Image
3-
4-
print("enter image name :")
5-
image_name = str(input()) # image name with relative path
6-
7-
img = Image.open(image_name)
8-
mywidth = img.size[0]
9-
myheight = img.size[1]
10-
img = img.resize((mywidth, myheight), PIL.Image.ANTIALIAS)
11-
img.save("Resized_Image.jpeg")
2+
img = Image.open('1.jpg') ## file name of relative path with file name (with extension)
3+
h,w = img.size ## getting height and width of image
4+
img = img.resize((h,w),Image.ANTIALIAS) ## compression
5+
img.save('1_compressed.jpg') ## output location and file name
6+
print("Image Compression Process Successfully Completed !! ")

Compress Image/demo.jpg

-1.14 MB
Binary file not shown.

0 commit comments

Comments
 (0)