{"id":13902419,"url":"https://github.com/vinodbaste/Image-compressor","last_synced_at":"2025-07-18T00:31:30.908Z","repository":{"id":48662532,"uuid":"516982114","full_name":"vinodbaste/Image-compressor","owner":"vinodbaste","description":"An Android Image compress library, reduce's the size of the image by 90% without losing any of its pixels.","archived":false,"fork":false,"pushed_at":"2023-04-12T11:08:14.000Z","size":705,"stargazers_count":33,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-15T15:23:15.752Z","etag":null,"topics":["android","android-app","android-application","android-development","android-library","android-plugin","androidstudio","compression","compression-library","dependencies","developwithgoogle","gradle-android-plugin","image-compressor","jetpack-compose","kotlin","kotlin-android","photos"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/vinodbaste.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}},"created_at":"2022-07-23T06:53:11.000Z","updated_at":"2024-11-13T13:50:59.000Z","dependencies_parsed_at":"2024-03-30T23:32:33.068Z","dependency_job_id":"0478f3ab-a79d-4c0e-b542-1d3c35819b5b","html_url":"https://github.com/vinodbaste/Image-compressor","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinodbaste%2FImage-compressor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinodbaste%2FImage-compressor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinodbaste%2FImage-compressor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinodbaste%2FImage-compressor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vinodbaste","download_url":"https://codeload.github.com/vinodbaste/Image-compressor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226310588,"owners_count":17604606,"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-app","android-application","android-development","android-library","android-plugin","androidstudio","compression","compression-library","dependencies","developwithgoogle","gradle-android-plugin","image-compressor","jetpack-compose","kotlin","kotlin-android","photos"],"created_at":"2024-08-06T22:01:08.489Z","updated_at":"2024-11-25T10:32:05.667Z","avatar_url":"https://github.com/vinodbaste.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/bastevinod"],"categories":["Kotlin"],"sub_categories":[],"readme":"# Image Compressor\n\nAn Android image compress library, **image compressor**, is small and effective. With very little or no image quality degradation, a compressor enables you to reduce the size of large photos into smaller size photos.\n\n[![Google DevLibrary - VinodBaste](https://img.shields.io/badge/Google_DevLibrary-VinodBaste-ea9f2d?logo=\u003csvg+role%3D\"img\"+viewBox%3D\"0+0+24+24\"+xmlns%3D\"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg\"\u003e\u003ctitle\u003eAndroid\u003c%2Ftitle\u003e\u003cpath+d%3D\"M17.523+15.3414c-.5511+0-.9993-.4486-.9993-.9997s.4483-.9993.9993-.9993c.5511+0+.9993.4483.9993.9993.0001.5511-.4482.9997-.9993.9997m-11.046+0c-.5511+0-.9993-.4486-.9993-.9997s.4482-.9993.9993-.9993c.5511+0+.9993.4483.9993.9993+0+.5511-.4483.9997-.9993.9997m11.4045-6.02l1.9973-3.4592a.416.416+0+00-.1521-.5676.416.416+0+00-.5676.1521l-2.0223+3.503C15.5902+8.2439+13.8533+7.8508+12+7.8508s-3.5902.3931-5.1367+1.0989L4.841+5.4467a.4161.4161+0+00-.5677-.1521.4157.4157+0+00-.1521.5676l1.9973+3.4592C2.6889+11.1867.3432+14.6589+0+18.761h24c-.3435-4.1021-2.6892-7.5743-6.1185-9.4396\"%2F\u003e\u003c%2Fsvg\u003e\u0026logoColor=30DC80)](https://devlibrary.withgoogle.com/products/android/repos/vinodbaste-Image-compressor)\n\n[![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21)\n[![GitHub tag](https://img.shields.io/github/tag/vinodbaste/image-compressor?include_prereleases=\u0026sort=semver\u0026color=blue)](https://github.com/vinodbaste/image-compressor/releases/)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue)](#license)\n[![News - Android Weekly](https://img.shields.io/badge/News-Android_Weekly-d36f21)](https://androidweekly.net/issues/issue-326)\n[![Story - Medium](https://img.shields.io/badge/Story-Medium-2ea44f)](https://medium.com/codex/image-compressor-13dbfd0445a3)\n[![GitHub - VinodBaste](https://img.shields.io/badge/GitHub-VinodBaste-4664c6)](https://github.com/vinodbaste/Image-compressor)\n[![](https://jitpack.io/v/vinodbaste/Image-compressor.svg)](https://jitpack.io/#vinodbaste/Image-compressor)\n\n\u003cimg src = \"https://raw.githubusercontent.com/vinodbaste/ImageCompressor/main/image%20(2)_google-pixel4xl-clearlywhite-portrait.jpg\" width = 250 height = 500 /\u003e\n\n# How to implement\nTo get a Git project into your build:\n## Gradle\n` Step 1:` Add it in your **root build.gradle**  at the end of repositories:\n```kotlin\nallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url 'https://jitpack.io' }\n\t\t}\n\t}\n```\n\n`Step 2:` Add the dependency in your **project build.gradle**\n```kotlin\ndependencies {\n\t        implementation 'com.github.vinodbaste:ImageCompressor:1.1.0'\n\t}\n```\n# Let's compress the image size!\n#### Compress Image File at the specified `imagePath`\nWhen **compressing** a picture, add the following block of code to the **activity or fragment**. Either after taking a **picture with a camera** or selecting one **from a gallery**.\n```kotlin\nImageCompressUtils.compressImage(\n            context = this,\n            imagePath = \"actualImagePath\",\n            imageName = \"imageName\",\n            imageQuality = 50\n        )\n```\n**compressImage** takes 4 parameters where the **last one is optional**\n* **context**, the current/active state of the application.\n* **imagePath** parameter takes the absolute image path.\n* **imageName** is completely up to the user.\n* **imageQuality** is set to 50 by default. The max can be set to 100.\n\n#### Compress Image File at the specified `imagePath` and return the `compressed ImagePath`\n```kotlin\nval compressedImagePath = ImageCompressUtils.compressImage(\n            context = this,\n            imagePath = \"actualImagePath\",\n            imageName = \"imageName\",\n            imageQuality = 50\n        )\n```\nWith the image name supplied, the code block above returns the path to the compressed picture.\n**compressedImagePath** has the imagePath with the imageName specified.\n\n# Example\nAn illustration of how the code block can be utilized.\n```kotlin\n \t //absolute path of the image\n        val imagePath= \"actualImagePath\"\n\n        val imageFileBc = File(imagePath)\n        val imageSizeBc = imageFileBc.length() / 1024 // In BYTES\n        Log.d(\"image_before_compress\", imageSizeBc.toString())\n\n        ImageCompressUtils.compressImage(\n            context = this,\n            imagePath = imagePath,\n            imageName = \"imageName\",\n            imageQuality = 50\n        )\n\n        val imageFileAc = File(imagePath)\n        val imageSizeAC = imageFileAc.length() / 1024 // In BYTES\n        Log.d(\"image_after_compress\", imageSizeAC.toString())\n\n        //your function to play with compressed image\n        loadCompressedImage(imagePath) \n```\n# proguard-rules\n```\n-keepclassmembers class com.android.imagecompressor.compressImageUtils\n\n-keep class * extends com.android.imagecompressor.compressImageUtils {\n \u003cinit\u003e(...);\n}\n\n-dontwarn javax.annotation.Nullable\n-dontwarn javax.annotation.ParametersAreNonnullByDefault\n```\n\n**If you find this library useful, please consider starring this repository from the top of this page.**\n[![](https://i.imgur.com/oSLuE0e.png)](#)\n\n# Support my work\n\u003ca href=\"https://www.buymeacoffee.com/bastevinod\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n\n# Note\n```\n\u003e In the event that an image is selected from a gallery, make a copy of it and follow the path.\n\u003e The original picture path is used to compress and rewrite the image.\n```\n# License\n```\nCopyright [2022] [Vinod Baste]\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinodbaste%2FImage-compressor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvinodbaste%2FImage-compressor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinodbaste%2FImage-compressor/lists"}