There are organizations who receive data form lakhs or more persons, which is mostly in form of text, with a few images. Most of you know that the text part is stored in databases in the form of tables, but what about the images? The images are small compared to the textual data but constitute a much higher space in terms of storage. Hence, to save on the part of space and keep running the processes smoothly, they ask the users to submit the compressed images. As most of the readers have a bit of CS background(either in school or college), they understand that using online free tools to compress images is not a good practice for them.
Till Windows 7, Microsoft used to give MS Office Picture Manager which could be used to compress images till an extent, but it also had some limitations.
Those who know a bit of python can install python and use pip install pillow in command prompt(terminal for Linux users) to install pillow fork.
You’ll get a screen like this
Assemble all the files in a folder and keep the file Compress.py in the same folder.
Run the python file with python.
Below is the Source Code of the file:
Folder Before Compression:
Command Line for executing Code:
PS: Please run code after getting into the directory.
Folder after execution of Code:
You can clearly see the compressed file.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Apply changes to all the images in given folder - Using Python PIL
- Loading Images in Tkinter using PIL
- Arithmetic Operations on Images using OpenCV | Set-2 (Bitwise Operations on Binary Images)
- Python | Numpy matrix.compress()
- Numpy recarray.compress() function | Python
- Python - Itertools.compress()
- zlib.compress(s) in python
- gzip.compress(s) in Python
- bz2.compress(s) in Python
- numpy.compress() in Python
- Python | Using PIL ImageGrab and PyTesseract
- Create Certificates using Python-PIL
- Python | Create video using multiple images using OpenCV
- Python PIL | logical_and() and logical_or() method
- Python PIL | ImageChops.subtract() and ImageChops.subtract_modulo() method
- Python PIL | ImageEnhance.Color() and ImageEnhance.Contrast() method
- Python PIL | ImageChops.screen() and ImageChops.offset() method
- Python PIL | MedianFilter() and ModeFilter() method
- Python PIL | getbands() and getextrema() method
- Python PIL | paste() and rotate() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.