Python 3 Script to Compress or Minify Image Size Using Pillow and Numpy Library (K-means Algorithm) Full Project For Beginners


Welcome folks today in this post we will be compressing image using pillow and numpy library. We will be using python script for this purpose and we will be making use of k-means algorithm. All the full source code of the application is given below.




Get Started




In order to get started we need to install the following libraries using the pipcommand


pip install pillow


pip install numpy


After installing these libraries we need to make an file and copy paste the following code





Now you just need to execute this pythonscript and also you need to pass the path of image as the argument to the script as follows


python sample.jpg



So sample.jpg here is the path of the image it is there in the same directory so we are passing it to the script.


Leave a Reply