{"id":28922788,"url":"https://github.com/ahmaruff/kmeans-img-compress","last_synced_at":"2026-04-18T13:32:45.951Z","repository":{"id":300030788,"uuid":"998475683","full_name":"ahmaruff/kmeans-img-compress","owner":"ahmaruff","description":"Simple python image compression library using K-Means clustering","archived":false,"fork":false,"pushed_at":"2025-06-19T14:19:10.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-19T14:45:36.154Z","etag":null,"topics":["color-quantization","image-compression","image-processing","kmeans","kmeans-clustering","numpy","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahmaruff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-08T17:29:12.000Z","updated_at":"2025-06-19T14:19:13.000Z","dependencies_parsed_at":"2025-06-19T14:45:39.165Z","dependency_job_id":"01a7908b-a04c-4e54-bd8c-f93d0a9bddbc","html_url":"https://github.com/ahmaruff/kmeans-img-compress","commit_stats":null,"previous_names":["ahmaruff/kmeans-img-compress"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ahmaruff/kmeans-img-compress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmaruff%2Fkmeans-img-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmaruff%2Fkmeans-img-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmaruff%2Fkmeans-img-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmaruff%2Fkmeans-img-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmaruff","download_url":"https://codeload.github.com/ahmaruff/kmeans-img-compress/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmaruff%2Fkmeans-img-compress/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268457056,"owners_count":24253338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color-quantization","image-compression","image-processing","kmeans","kmeans-clustering","numpy","python"],"created_at":"2025-06-22T08:30:49.523Z","updated_at":"2026-04-18T13:32:40.911Z","avatar_url":"https://github.com/ahmaruff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K-Means Image Compress\n\nA simple Python library for image compression using K-Means clustering to reduce colors.\n\n## Background\n\nThis library is derived from my undergraduate thesis research on image compression using K-Means clustering algorithm. The research aimed to evaluate the performance of K-Means algorithm in digital image compression by extracting dominant color palettes and applying color quantization for image reconstruction.\n\nThe study explored the impact of cluster numbers (K) on compression ratio and Peak Signal to Noise Ratio (PSNR) values. Through experimental methods, RGB 24-bit images with various resolutions (VGA, SVGA, HD, FHD) were compressed using different cluster numbers (8, 16, 32, 64, 96, 128).\n\n**Key Research Results:**\n- K-Means algorithm proved effective with average compression ratio of **67%**\n- Average PSNR value of **81.43 dB** indicating good image quality retention\n- **96 clusters emerged as the optimal value** providing the best balance between compression quality and computational efficiency\n\nThe default value of 96 clusters in this library is based on these empirical findings from my thesis research.\n\n**Research Repository**:  \n[Image Compression using K-Means](https://github.com/ahmaruff/image-compression-using-kmeans)  \n\n**Paper**:  \n[Ma’ruf, A., Sibyan, H., \u0026 Mardiyantoro, N. (2025). *Ekstraksi Palet Warna untuk Kompresi Gambar Digital menggunakan Algoritma K-Means*. Jurnal Informatika dan Rekayasa Perangkat Lunak, 7(1), 134–141.](https://publikasiilmiah.unwahas.ac.id/JINRPL/issue/view/540)\n\n---\n\n## Installation\n\n### Install from GitHub\n\n```bash\n# Install directly from GitHub\npip install git+https://github.com/ahmaruff/kmeans-img-compress.git\n\n# Or clone and install locally\ngit clone https://github.com/ahmaruff/kmeans-img-compress.git\ncd kmeans-img-compress\npip install .\n\n# For development (editable install)\npip install -e .\n```\n\n## Quick Start\n\n```python\nimport kmeans_img_compress as kic\n\n# Basic compression with research-optimized default (96 clusters)\nstats = kic.compress(\"input.jpg\", \"output.jpg\")\nprint(f\"Size reduced by {stats['size_reduction_percent']:.1f}%\")\n\n# Custom compression\nstats = kic.compress(\"input.jpg\", \"output.jpg\", n_colors=64, quality=80)\nprint(f\"Compression ratio: {stats['compression_ratio']:.2f}\")\n\n# Get image info and recommendations\ninfo = kic.get_compression_info(\"input.jpg\")\nprint(f\"Original size: {info['file_size_mb']:.2f} MB\")\nprint(f\"Recommended clusters: {info['recommended_clusters']}\")\n```\n\n## Features\n\n- Simple K-Means based color reduction\n- Memory efficient processing for large images\n- Multiple output formats (JPEG, PNG, WEBP)\n- Detailed compression statistics\n- Automatic parameter recommendations\n\n## Requirements\n\n- Python 3.7+\n- NumPy\n- Pillow\n- scikit-learn\n\n## License\n\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmaruff%2Fkmeans-img-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmaruff%2Fkmeans-img-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmaruff%2Fkmeans-img-compress/lists"}