All Projects → zetbaitsu → Compressor

zetbaitsu / Compressor

Licence: other
An android image compression library.

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Compressor

imagezero
Fast Lossless Color Image Compression Library
Stars: ✭ 49 (-99.27%)
Mutual labels:  compression, compress-images, image-compression
Turbopfor Integer Compression
Fastest Integer Compression
Stars: ✭ 520 (-92.29%)
Mutual labels:  compression, compressor
Rust Brotli
Brotli compressor and decompressor written in rust that optionally avoids the stdlib
Stars: ✭ 504 (-92.53%)
Mutual labels:  compression, compressor
Stdpack.c
Collection of small public domain de/compressors in plain C.
Stars: ✭ 73 (-98.92%)
Mutual labels:  compression, compressor
roadroller
Roadroller: Flattens Your JavaScript Demo
Stars: ✭ 253 (-96.25%)
Mutual labels:  compression, compressor
Lizard
Lizard (formerly LZ5) is an efficient compressor with very fast decompression. It achieves compression ratio that is comparable to zip/zlib and zstd/brotli (at low and medium compression levels) at decompression speed of 1000 MB/s and faster.
Stars: ✭ 408 (-93.95%)
Mutual labels:  compression, compressor
Image Actions
A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
Stars: ✭ 844 (-87.49%)
Mutual labels:  compression, image-compression
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (-97.52%)
Mutual labels:  compression, compressor
Compression
Learned image compression
Stars: ✭ 79 (-98.83%)
Mutual labels:  compression, image-compression
Lerc
Limited Error Raster Compression
Stars: ✭ 126 (-98.13%)
Mutual labels:  compression, image-compression
Minify
CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.
Stars: ✭ 1,710 (-74.65%)
Mutual labels:  compression, compressor
Compress Images
Minify size your images. Image compression with extension: jpg/jpeg, svg, png, gif. NodeJs
Stars: ✭ 331 (-95.09%)
Mutual labels:  compression, image-compression
Crunch
Crunch is a tool for lossy PNG image file optimization. It combines selective bit depth, color type, and color palette reduction with zopfli DEFLATE compression algorithm encoding using the pngquant and zopflipng PNG optimization tools. This approach leads to a significant file size gain relative to lossless approaches at the expense of a relatively modest decrease in image quality (see example images below).
Stars: ✭ 3,074 (-54.43%)
Mutual labels:  compression, image-compression
Lzbench
lzbench is an in-memory benchmark of open-source LZ77/LZSS/LZMA compressors
Stars: ✭ 490 (-92.74%)
Mutual labels:  compression, compressor
Imager
Automated image compression for efficiently distributing images on the web.
Stars: ✭ 266 (-96.06%)
Mutual labels:  compression, image-compression
Caesium Image Compressor
Caesium is a cross-platform image compression software aimed at helping photographers, bloggers, webmasters, businesses or casual users at storing, sending and sharing digital pictures. Based on libcaesium.
Stars: ✭ 595 (-91.18%)
Mutual labels:  compression, image-compression
Turbobench
Compression Benchmark
Stars: ✭ 211 (-96.87%)
Mutual labels:  compression, compressor
TinyJPG
images jpg or jpeg compressed and watcher fsnotify
Stars: ✭ 73 (-98.92%)
Mutual labels:  compression, image-compression
libcaesium
The Caesium compression library written in Rust
Stars: ✭ 58 (-99.14%)
Mutual labels:  compression, image-compression
Squeezer
Flexible general-purpose compressor with a touch of citrus
Stars: ✭ 78 (-98.84%)
Mutual labels:  compression, compressor

Compressor

Android Arsenal Build Status codecov

Compressor 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.

Gradle

dependencies {
    implementation 'id.zelory:compressor:3.0.1'
}

Let's compress the image size!

Compress Image File

val compressedImageFile = Compressor.compress(context, actualImageFile)

Compress Image File to specific destination

val compressedImageFile = Compressor.compress(context, actualImageFile) {
    default()
    destination(myFile)
}

I want custom Compressor!

Using default constraint and custom partial of it

val compressedImageFile = Compressor.compress(context, actualImageFile) {
    default(width = 640, format = Bitmap.CompressFormat.WEBP)
}

Full custom constraint

val compressedImageFile = Compressor.compress(context, actualImageFile) {
    resolution(1280, 720)
    quality(80)
    format(Bitmap.CompressFormat.WEBP)
    size(2_097_152) // 2 MB
}

Using your own custom constraint

class MyLowerCaseNameConstraint: Constraint {
    override fun isSatisfied(imageFile: File): Boolean {
        return imageFile.name.all { it.isLowerCase() }
    }

    override fun satisfy(imageFile: File): File {
        val destination = File(imageFile.parent, imageFile.name.toLowerCase())
        imageFile.renameTo(destination)
        return destination
    }
}

val compressedImageFile = Compressor.compress(context, actualImageFile) {
    constraint(MyLowerCaseNameConstraint()) // your own constraint
    quality(80) // combine with compressor constraint
    format(Bitmap.CompressFormat.WEBP)
}

You can create your own extension too

fun Compression.lowerCaseName() {
    constraint(MyLowerCaseNameConstraint())
}

val compressedImageFile = Compressor.compress(context, actualImageFile) {
    lowerCaseName() // your own extension
    quality(80) // combine with compressor constraint
    format(Bitmap.CompressFormat.WEBP)
}

Compressor now is using Kotlin coroutines!

Calling Compressor should be done from coroutines scope

// e.g calling from activity lifecycle scope
lifecycleScope.launch {
    val compressedImageFile = Compressor.compress(context, actualImageFile)
}

// calling from global scope
GlobalScope.launch {
    val compressedImageFile = Compressor.compress(context, actualImageFile)
}

Run Compressor in main thread

val compressedImageFile = Compressor.compress(context, actualImageFile, Dispatchers.Main)

Old version

Please read this readme

License

Copyright (c) 2016 Zetra.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].