Skip to content

Commit 9b07800

Browse files
authored
Merge pull request larymak#37 from xolanigumbi/main
Modified the code for 'Compress Image'
2 parents 662c48e + d837f84 commit 9b07800

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Compress Image/1_compressed.jpg

-1.67 MB
Binary file not shown.

Compress Image/code.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

Compress Image/img_comp.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from PIL import Image
2+
3+
def compress_image(default_image=Image.open('original_image.jpg')):
4+
''' Takes an image file and compress it with losing image quality. '''
5+
6+
''' If no image file is provided, the default image will be compressed '''
7+
8+
# Get image 'width' and 'height'
9+
w, h = default_image.size
10+
# compress image
11+
default_image = default_image.resize((h, w), Image.ANTIALIAS)
12+
# return compressed image
13+
return default_image.save('compressed_image.jpg')
14+
15+
# Run
16+
compress_image()
File renamed without changes.

0 commit comments

Comments
 (0)