{"id":3522,"url":"https://github.com/zetbaitsu/Compressor","last_synced_at":"2025-08-03T20:32:27.403Z","repository":{"id":37405475,"uuid":"61435800","full_name":"zetbaitsu/Compressor","owner":"zetbaitsu","description":"An android image compression library.","archived":false,"fork":false,"pushed_at":"2023-11-21T11:33:17.000Z","size":900,"stargazers_count":7086,"open_issues_count":140,"forks_count":963,"subscribers_count":144,"default_branch":"master","last_synced_at":"2024-12-03T13:02:19.474Z","etag":null,"topics":["android","android-library","compress-images","compression","compressor","image-compression","kotlin","kotlin-android","kotlin-coroutines","kotlin-library","photos"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zetbaitsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"ko_fi":"zetbaitsu"}},"created_at":"2016-06-18T13:54:59.000Z","updated_at":"2024-12-03T06:53:05.000Z","dependencies_parsed_at":"2024-06-18T16:53:56.078Z","dependency_job_id":"ef72b207-0249-46ae-98c9-013b6382ce81","html_url":"https://github.com/zetbaitsu/Compressor","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetbaitsu%2FCompressor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetbaitsu%2FCompressor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetbaitsu%2FCompressor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetbaitsu%2FCompressor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zetbaitsu","download_url":"https://codeload.github.com/zetbaitsu/Compressor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228567009,"owners_count":17937983,"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":["android","android-library","compress-images","compression","compressor","image-compression","kotlin","kotlin-android","kotlin-coroutines","kotlin-library","photos"],"created_at":"2024-01-05T20:16:43.898Z","updated_at":"2024-12-07T05:30:34.521Z","avatar_url":"https://github.com/zetbaitsu.png","language":"Kotlin","readme":"Compressor\n======\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Compressor-blue.svg?style=flat)](http://android-arsenal.com/details/1/3758)\n[![Build Status](https://travis-ci.org/zetbaitsu/Compressor.svg?branch=master)](https://travis-ci.org/zetbaitsu/Compressor)\n[![codecov](https://codecov.io/gh/zetbaitsu/Compressor/branch/master/graph/badge.svg)](https://codecov.io/gh/zetbaitsu/Compressor)\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/zetbaitsu/Compressor/master/ss.png\" width=\"50%\" /\u003e\u003c/p\u003e\nCompressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller sized photos with very less or negligible loss in quality of the image.\n\n# Gradle\n```groovy\ndependencies {\n    implementation 'id.zelory:compressor:3.0.1'\n}\n```\n# Let's compress the image size!\n#### Compress Image File\n```kotlin\nval compressedImageFile = Compressor.compress(context, actualImageFile)\n```\n#### Compress Image File to specific destination\n```kotlin\nval compressedImageFile = Compressor.compress(context, actualImageFile) {\n    default()\n    destination(myFile)\n}\n```\n### I want custom Compressor!\n#### Using default constraint and custom partial of it\n```kotlin\nval compressedImageFile = Compressor.compress(context, actualImageFile) {\n    default(width = 640, format = Bitmap.CompressFormat.WEBP)\n}\n```\n#### Full custom constraint\n```kotlin\nval compressedImageFile = Compressor.compress(context, actualImageFile) {\n    resolution(1280, 720)\n    quality(80)\n    format(Bitmap.CompressFormat.WEBP)\n    size(2_097_152) // 2 MB\n}\n```\n#### Using your own custom constraint\n```kotlin\nclass MyLowerCaseNameConstraint: Constraint {\n    override fun isSatisfied(imageFile: File): Boolean {\n        return imageFile.name.all { it.isLowerCase() }\n    }\n\n    override fun satisfy(imageFile: File): File {\n        val destination = File(imageFile.parent, imageFile.name.toLowerCase())\n        imageFile.renameTo(destination)\n        return destination\n    }\n}\n\nval compressedImageFile = Compressor.compress(context, actualImageFile) {\n    constraint(MyLowerCaseNameConstraint()) // your own constraint\n    quality(80) // combine with compressor constraint\n    format(Bitmap.CompressFormat.WEBP)\n}\n```\n#### You can create your own extension too\n```kotlin\nfun Compression.lowerCaseName() {\n    constraint(MyLowerCaseNameConstraint())\n}\n\nval compressedImageFile = Compressor.compress(context, actualImageFile) {\n    lowerCaseName() // your own extension\n    quality(80) // combine with compressor constraint\n    format(Bitmap.CompressFormat.WEBP)\n}\n```\n\n### Compressor now is using Kotlin coroutines!\n#### Calling Compressor should be done from coroutines scope\n```kotlin\n// e.g calling from activity lifecycle scope\nlifecycleScope.launch {\n    val compressedImageFile = Compressor.compress(context, actualImageFile)\n}\n\n// calling from global scope\nGlobalScope.launch {\n    val compressedImageFile = Compressor.compress(context, actualImageFile)\n}\n```\n#### Run Compressor in main thread\n```kotlin\nval compressedImageFile = Compressor.compress(context, actualImageFile, Dispatchers.Main)\n```\n\n### Old version\nPlease read this [readme](https://github.com/zetbaitsu/Compressor/blob/master/README_v2.md)\n\nLicense\n-------\n    Copyright (c) 2016 Zetra.\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":["https://ko-fi.com/zetbaitsu"],"categories":["Image Processing","Libraries","Android","Kotlin","Android应用"],"sub_categories":["GUI","Android libraries","ImageView","资源传输下载"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzetbaitsu%2FCompressor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzetbaitsu%2FCompressor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzetbaitsu%2FCompressor/lists"}