• Stars
    star
    2,601
  • Rank 17,613 (Top 0.4 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

an image compression framework.(一个高保真、高压缩比的图片压缩框架)

Tiny

an image compression framework.


Download Travis Hex.pm

Blog entry with introduction or Introduction of compression

Effect of compression

ImageInfo Tiny Wechat
6.66MB (3500x2156) 151KB (1280x788) 135KB (1280x788)
4.28MB (4160x3120) 219KB (1280x960) 195KB (1280x960)
2.60MB (4032x3024) 193KB (1280x960) 173KB (1280x960)
372KB (500x500) 38.67KB (500x500) 34.05KB (500x500)
236KB (960x1280) 127KB (960x1280) 118KB (960x1280)

Introduce

Tiny does not depend on any library , it keeps the code clean on architecture . Tiny also uses an asynchronous thread pool to compress images , and will hand out the result in the main thread when compression is completed.

Usage

Installation

implementation 'com.zxy.android:tiny:1.1.0'

Choose an abi

Tiny provide abi:armeabiarmeabi-v7aarm64-v8ax86.

Choose what you need "abi" version:

android {
    defaultConfig {
        ndk {
            abiFilters 'armeabi','x86'//or armeabi-v7a、arm64-v8a、x86
        }
    }
}

Initialization

        Tiny.getInstance().init(this);

Compression

AsBitmap

        Tiny.BitmapCompressOptions options = new Tiny.BitmapCompressOptions();
        //options.height = xxx;//some compression configuration.
        Tiny.getInstance().source("").asBitmap().withOptions(options).compress(new BitmapCallback() {
            @Override
            public void callback(boolean isSuccess, Bitmap bitmap, Throwable t) {
                //return the compressed bitmap object
            }
        });
        
        //or sync compress.
        BitmapResult result = Tiny.getInstance().source("").asBitmap().withOptions(options).compressSync();

AsFile

        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
        Tiny.getInstance().source("").asFile().withOptions(options).compress(new FileCallback() {
            @Override
            public void callback(boolean isSuccess, String outfile, Throwable t) {
                //return the compressed file path
            }
        });
        
        //or sync compress.
        FileResult result = Tiny.getInstance().source("").asFile().withOptions(options).compressSync();

AsFileWithReturnBitmap

        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
        Tiny.getInstance().source("").asFile().withOptions(options).compress(new FileWithBitmapCallback() {
            @Override
            public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {
                //return the compressed file path and bitmap object
            }
        });
        
        //or sync compress.
        FileWithBitmapResult result = Tiny.getInstance().source("").asFile().withOptions(options).compressWithReturnBitmapSync();

BatchAsBitmap

        Tiny.BitmapCompressOptions options = new Tiny.BitmapCompressOptions();
        Tiny.getInstance().source("").batchAsBitmap().withOptions(options).batchCompress(new BitmapBatchCallback() {
            @Override
            public void callback(boolean isSuccess, Bitmap[] bitmaps, Throwable t) {
                //return the batch compressed bitmap object
            }
        });
        
        //or sync compress.
        BitmapBatchResult result = Tiny.getInstance().source("").batchAsBitmap().withOptions(options).batchCompressSync();

BatchAsFile

        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
        Tiny.getInstance().source("").batchAsFile().withOptions(options).batchCompress(new FileBatchCallback() {
            @Override
            public void callback(boolean isSuccess, String[] outfile, Throwable t) {
                //return the batch compressed file path
            }
        });
        
        //or sync compress.
        FileBatchResult result = Tiny.getInstance().source("").batchAsFile().withOptions(options).batchCompressSync();

BatchAsFileWithReturnBitmap

        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
        Tiny.getInstance().source("").batchAsFile().withOptions(options).batchCompress(new FileWithBitmapBatchCallback() {
            @Override
            public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile, Throwable t) {
                //return the batch compressed file path and bitmap object
            }
        });
        
        //or sync compress.
        FileWithBitmapBatchResult result = Tiny.getInstance().source("").batchAsFile().withOptions(options).batchCompressWithReturnBitmapResult();

Version

  • v0.0.1:The first version.
  • v0.0.2:Optimize the compression strategy,and handle with the orientation of bitmap.
  • v0.0.3:Unified as libtiny.so
  • v0.0.4:Add cover source file configuration—see{@link FileCompressOptions#overrideSource}, and setting up the batch compressed file paths—see {@link BatchFileCompressOptions#outfiles}
  • v0.0.5:Fix google store reject.
  • v0.0.6:Initialization is not must.Add clear compression directory method,see{@link Tiny#clearCompressDirectory}
  • v0.0.7:fix issue#29
  • v0.1.0:Add exception thrown interface, add the Throwable parameter to the callback method {@link xxxxCallback#callback}, see Update Introduce
  • v1.0.0:Add synchronous compression method and compression directory Settings.
  • v1.1.0:Add baseline setting support.

About

License

Apache License

Version 2.0, January 2004
http://www.apache.org/licenses/

Copyright 2018 郑晓勇

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.

More Repositories

1

Recovery

a crash recovery framework.(一个App异常恢复框架)
Java
1,705
star
2

JsBridge

js and java call each other.(一个JS与Java互相通信框架)
Java
195
star
3

ApiInspect

An api compatibility inspect gradle plugin.(一个Api兼容性检测的Gradle插件)
Groovy
90
star
4

UrlRouter

a routing framework support via the url to jump to the activity.
Java
75
star
5

Android-ScalingActivityAnimator

an interesting pop-view animation.
Java
51
star
6

FFmpeg-Compile-For-Android

Compile FFmpeg shared libraries for android platform.
Shell
36
star
7

Android-QuickReturnHeaderAndFooter

a quick return effect, use a custom CoordinatorLayout.Behavior.
Java
25
star
8

SwipeBackActivity

A gesture activity support sliding back to the right!
Java
24
star
9

findViewById-support

The IDEA plugin for generate findViewById code automatic. Support Java and Kotlin.(一个自动生成FindViewById的IDEA插件,支持Java和Kotlin)
Java
20
star
10

FrescoPlus

fresco library of secondary packaging.
Java
19
star
11

flutter-wrapper-cli

Batchfile
8
star
12

external-plugin-support

The IDEA plugin to show the source code [Groovy、Java、Class] for Android Gradle Plugin and Custom Gradle Plugin. Such as External Libraries.(一个用于显示Gradle Plugin源码树的IDEA插件,类似External Libraries)
8
star
13

gradle-plugin-support

The IDEA plugin for help to create and develop a standard Gradle Plugin project.(一个用于创建和开发一个标准的Gradle Plugin工程的IDEA插件,包含生成标准的Gradle Plugin工程、BuildSrc工程与Groovy Class)
Java
8
star
14

PullToLoad

a refresh framework supports any view and multiple nested views, and contains the wrapper which can load more.
Java
6
star
15

AsyncExecutor

An asynchronous task processing lightweight framework!
Java
3
star
16

Librtmp-Compile-For-Android

Compile Librtmp shared libraries for android platform.
C
3
star
17

langtools

The langtools repository of OpenJDK , including javac source code.
Java
2
star
18

ImageRepository

Image Repository.
2
star
19

Android-DropAnimationSample

Animation with a timestamp drop down
Java
1
star