mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-02-17 13:58:10 +00:00
commit
7a91d8527e
17
scripts/ImageCompressor/imageCompressor.md
Normal file
17
scripts/ImageCompressor/imageCompressor.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
**Image Compression using PIL Python library**
|
||||||
|
|
||||||
|
It is CLI based program used to compress the images using PIL library.
|
||||||
|
|
||||||
|
Fixes #3
|
||||||
|
|
||||||
|
**Built With**
|
||||||
|
|
||||||
|
*Python (PIL Library)*
|
||||||
|
|
||||||
|
**Prerequisites**
|
||||||
|
1. `pip install pillow`
|
||||||
|
2. `pip install argparse`
|
||||||
|
|
||||||
|
**Run project in CLI**
|
||||||
|
|
||||||
|
`python imageCompressor.py file-name`
|
16
scripts/ImageCompressor/imageCompressor.py
Normal file
16
scripts/ImageCompressor/imageCompressor.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from PIL import Image
|
||||||
|
from tkinter.filedialog import *
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
def compressImage(filename):
|
||||||
|
img = Image.open(filename)
|
||||||
|
myHeight, myWidth = img.size
|
||||||
|
img = img.resize((myHeight,myWidth), Image.ANTIALIAS)
|
||||||
|
img.save("compressed-"+filename)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("img",type = str)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
compressImage(args.img)
|
1
scripts/ImageCompressor/requirement.txt
Normal file
1
scripts/ImageCompressor/requirement.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Pillow==9.1.0
|
Loading…
Reference in New Issue
Block a user