Skip to content

Commit

Permalink
Merge branch 'master' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vinodbaste authored Apr 12, 2023
2 parents 6262da6 + 593f327 commit 6f0fc9d
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Android CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
45 changes: 45 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build

# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: publish
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Vinod Baste

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Image Compressor

The Android image compression 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 photos.
An 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.

[![Google DevLibrary - VinodBaste](https://img.shields.io/badge/Google_DevLibrary-VinodBaste-ea9f2d?logo=<svg+role%3D"img"+viewBox%3D"0+0+24+24"+xmlns%3D"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg"><title>Android<%2Ftitle><path+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><%2Fsvg>&logoColor=30DC80)](https://devlibrary.withgoogle.com/products/android/repos/vinodbaste-Image-compressor)

[![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21)
[![GitHub tag](https://img.shields.io/github/tag/vinodbaste/image-compressor?include_prereleases=&sort=semver&color=blue)](https://github.com/vinodbaste/image-compressor/releases/)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue)](#license)
[![News - Android Weekly](https://img.shields.io/badge/News-Android_Weekly-d36f21)](https://androidweekly.net/issues/issue-326)
[![Story - Medium](https://img.shields.io/badge/Story-Medium-2ea44f)](https://medium.com/codex/image-compressor-13dbfd0445a3)
[![GitHub - VinodBaste](https://img.shields.io/badge/GitHub-VinodBaste-4664c6)](https://github.com/vinodbaste/Image-compressor)

<img src = "https://github.com/raw/vinodbaste/ImageCompressor/main/image%20(2)_google-pixel4xl-clearlywhite-portrait.jpg" width = 250 height = 500 />

# How to
# How to implement
To get a Git project into your build:
## Gradle
` Step 1:` Add it in your **root build.gradle** at the end of repositories:
Expand All @@ -25,6 +34,7 @@ dependencies {
```
# Let's compress the image size!
#### Compress Image File at the specified `imagePath`
When **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**.
```kotlin
ImageCompressUtils.compressImage(
context = this,
Expand All @@ -33,7 +43,11 @@ ImageCompressUtils.compressImage(
imageQuality = 50
)
```
**imageQuality** is set to `50` by default.
**compressImage** takes 4 parameters where the **last one is optional**
* **context**, the current/active state of the application.
* **imagePath** parameter takes the absolute image path.
* **imageName** is completely up to the user.
* **imageQuality** is set to 50 by default. The max can be set to 100.

#### Compress Image File at the specified `imagePath` and return the `compressed ImagePath`
```kotlin
Expand All @@ -44,8 +58,11 @@ val compressedImagePath = ImageCompressUtils.compressImage(
imageQuality = 50
)
```
With the image name supplied, the code block above returns the path to the compressed picture.
**compressedImagePath** has the imagePath with the imageName specified.

# Example
An illustration of how the code block can be utilized.
```kotlin
//absolute path of the image
val imagePath= "actualImagePath"
Expand All @@ -68,11 +85,28 @@ val compressedImagePath = ImageCompressUtils.compressImage(
//your function to play with compressed image
loadCompressedImage(imagePath)
```
# proguard-rules
```
-keepclassmembers class com.android.imagecompressor.compressImageUtils
-keep class * extends com.android.imagecompressor.compressImageUtils {
<init>(...);
}
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault
```

**If you find this library useful, please consider starring this repository from the top of this page.**
[![](https://i.imgur.com/oSLuE0e.png)](#)

# Support my work
<a href="https://www.buymeacoffee.com/bastevinod" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

# Note
```
> Do make a copy of the image and pass the path if the image is choosen from gallery.
> Image is compressed at the original image path and re-written at the same path.
> In the event that an image is selected from a gallery, make a copy of it and follow the path.
> The original picture path is used to compress and rewrite the image.
```
# License
```
Expand Down
1 change: 1 addition & 0 deletions google6401b219a8c25f30.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-site-verification: google6401b219a8c25f30.html

0 comments on commit 6f0fc9d

Please sign in to comment.