A simple python command line app to compress images. It can be used to seamlessly compress and decompress images in .png, .bmp, .tiff, .git, .exif and other image formats. Does not have .jpg support as they are already highly compressed. It uses the K-Means Algorithm to form clusters which is representative of its mean color. It then uses these mean colors to decompress the image back. A sample outcome for this program with number of clusters set to 16
For OSX : You should have Python 3.0 or greater to run this program. Check this
python3 --versionPython libraries numpy and scikit-image should installed. If not, depending on which ones are not present, run
brew install python3 numpy skimagecd into the directory where you cloned the repository.
cd ./path-to-repository/
tar -xf Image-Compressor-master.zip
cd Image-Compressor-masterrun the program img_compress.py
python3 img_compress.pyTo compress an image, simply enter the image name and the number of clusters. The more clusters, the lesser the compression will be and the better the reconstructed image will be at the cost of a greater running time. Remember that compressing may take a while although decompression will be quick.
image-to-compress.png 16You will see two new files 'image-to-compress_clusters.png' and 'image-to-compress_means.npy'. These contain the data to reconstruct the original image.
To reconstruct the original image, you need to have the 'image-to-compress_clusters.png' and 'image-to-compress_means.npy' compressed data files in the same folder. Now run img_decompress.py
image-to-compress.pngThe final decompressed image will be created.

