{"id":29602000,"url":"https://github.com/neilveil/compression-loop","last_synced_at":"2025-07-20T13:37:21.995Z","repository":{"id":197411079,"uuid":"678285287","full_name":"neilveil/compression-loop","owner":"neilveil","description":"Optimally compress image in browser to the target size","archived":false,"fork":false,"pushed_at":"2024-02-02T07:56:57.000Z","size":62,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-05T21:13:45.895Z","etag":null,"topics":["browser-image-compression","client-side-image-compression","compress-image","image-compressor","lossy-compression","web-compressor"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/compression-loop","language":"TypeScript","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/neilveil.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","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}},"created_at":"2023-08-14T07:39:54.000Z","updated_at":"2024-06-22T14:57:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"975f13ac-63c9-4a36-b389-b3f5266ffdba","html_url":"https://github.com/neilveil/compression-loop","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":"0.15384615384615385","last_synced_commit":"39a8d983292f10950a73d5e7d019851efe101476"},"previous_names":["neilveil/compression-loop"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/neilveil/compression-loop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neilveil%2Fcompression-loop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neilveil%2Fcompression-loop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neilveil%2Fcompression-loop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neilveil%2Fcompression-loop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neilveil","download_url":"https://codeload.github.com/neilveil/compression-loop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neilveil%2Fcompression-loop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266135063,"owners_count":23881775,"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","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":["browser-image-compression","client-side-image-compression","compress-image","image-compressor","lossy-compression","web-compressor"],"created_at":"2025-07-20T13:37:11.819Z","updated_at":"2025-07-20T13:37:21.983Z","avatar_url":"https://github.com/neilveil.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ✨ Compression Loop ✨\r\n\r\n![Downloads](https://img.shields.io/npm/dm/compression-loop.svg)\r\n![Version](https://img.shields.io/npm/v/compression-loop.svg)\r\n![License](https://img.shields.io/npm/l/compression-loop.svg)\r\n\r\nCompression Loop allows you to optimally compress images in the browser to the target size. This package utilizes an iterative approach called **Quality Descent**, to find the optimal balance between image quality and file size.\r\n\r\nThe **Quality Descent Algorithm** is utilized in the package which finds the optimal quality index to compress the image to the target size.\r\n\r\n## Features 🌟\r\n\r\n- **In-Browser Image Compression**: Seamlessly compress images directly within the web browser, enabling efficient image optimization without the need for server-side processing.\r\n\r\n- **Customizable Target Image Size**: Specify precise target image sizes to align with your application's specific demands, ensuring optimal file size management.\r\n\r\n- **Progress Callback Support**: Monitor the compression progress with the built-in callback feature, allowing you to track and display compression status to users for a more interactive experience.\r\n\r\n- **Lightweight and Dependency-Free**: Developed with a focus on efficiency, the package is incredibly lightweight, with a file size of less than 1 kilobyte, and operates independently without any external dependencies.\r\n\r\n- **Client-Side Processing**: By shifting the image compression workload to the client side, this package reduces the strain on server resources, resulting in significant time and resource savings.\r\n\r\n## Installation 🚀\r\n\r\nTo install the Compression Loop package, you can use npm:\r\n\r\n```bash\r\nnpm install compression-loop\r\n```\r\n\r\n## Usage 🛠️\r\n\r\nHere's a basic example of how to use Compression Loop to compress images:\r\n\r\n```jsx\r\nconst compressionLoop = require('compression-loop');\r\n\r\n..\r\n\r\n\u003cinput\r\n  type='file'\r\n  accept='image/jpeg'\r\n  onChange={async (e) =\u003e {\r\n    const img = e.target.files[0]\r\n\r\n    const { status, compressedImg } = await CompressionLoop({ img })\r\n\r\n    if (status === 'success') {\r\n      console.log('Image compressed', compressedImg)\r\n    } else console.log(status)\r\n  }}\r\n/\u003e\r\n```\r\n\r\n| Argument     | Type     | Usage                                    |\r\n|--------------|----------|------------------------------------------|\r\n| *img         | Blob     | Source image                             |\r\n| *maxSize     | Number   | Max allowed size in bytes                |\r\n| onProgress   | Function | Track progress                           |\r\n| timeout      | Number   | Max processing time in milliseconds      |\r\n| maxIteration | Number   | Max compression iterations               |\r\n| quality      | Number   | Starting quality index (0-1], default: 1 |\r\n| descentIndex | Number   | Quality decrement rate, default: 0.1     |\r\n\r\n## License 📜\r\n\r\nThis package is open-source and available under the MIT License.\r\n\r\n## Contributing 🙌\r\n\r\nContributions to the Compression Loop package are welcome! If you have any ideas, improvements, or bug fixes, please submit a pull request or open an issue.\r\n\r\n## Authors 🖋️\r\n\r\nDeveloped \u0026 maintained by [neilveil](https://github.com/neilveil)\r\n\r\n\u003cimg src=\"https://github.com/neilveil/compression-loop/assets/29909602/413ea75a-136e-4721-b0b6-3b12161b408a\" alt=\"Quality Descent Algorithm by neilveil\" style=\"max-width: 400px;\" /\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneilveil%2Fcompression-loop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneilveil%2Fcompression-loop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneilveil%2Fcompression-loop/lists"}