MCPcopy Index your code
hub / github.com/Sunzxyong/Tiny

github.com/Sunzxyong/Tiny @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
1,924 symbols 4,430 edges 260 files 170 documented · 9% updated 5y agov1.0.0 · 2018-10-27★ 2,63164 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

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.

Extension points exported contracts — how you extend this code

FileBatchCallback (Interface)
Created by zhengxiaoyong on 2017/3/31. [8 implementers]
tiny/src/main/java/com/zxy/tiny/callback/FileBatchCallback.java
TJCustomFilter (Interface)
Custom filter callback interface [2 implementers]
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
FileWithBitmapBatchCallback (Interface)
Created by zhengxiaoyong on 2017/3/31. [8 implementers]
tiny/src/main/java/com/zxy/tiny/callback/FileWithBitmapBatchCallback.java
BitmapBatchCallback (Interface)
Created by zhengxiaoyong on 2017/3/31. [8 implementers]
tiny/src/main/java/com/zxy/tiny/callback/BitmapBatchCallback.java
BitmapCallback (Interface)
Created by zhengxiaoyong on 2017/3/12. [8 implementers]
tiny/src/main/java/com/zxy/tiny/callback/BitmapCallback.java
FileCallback (Interface)
Created by zhengxiaoyong on 2017/3/12. [8 implementers]
tiny/src/main/java/com/zxy/tiny/callback/FileCallback.java

Core symbols most depended-on inside this repo

keymatch
called by 91
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/cdjpeg.c
call
called by 91
tiny/src/main/java/com/zxy/tiny/callable/FileCompressCallableTasks.java
close
called by 79
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/java/org/libjpegturbo/turbojpeg/TJCompressor.java
jdiv_round_up
called by 53
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/jutils.c
arith_encode
called by 49
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/jcarith.c
emit_byte
called by 44
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/jcmarker.c
getWidth
called by 44
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/java/org/libjpegturbo/turbojpeg/YUVImage.java
getHeight
called by 44
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/java/org/libjpegturbo/turbojpeg/YUVImage.java

Shape

Function 1,179
Method 387
Class 343
Interface 10
Enum 5

Languages

C64%
Java26%
C++8%
TypeScript3%

Modules by API surface

libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/simd/jsimd_mips.c63 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/jsimd_none.c60 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/turbojpeg.c56 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/simd/jsimd_powerpc.c53 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/simd/jsimd_arm64.c53 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/simd/jsimd_arm.c53 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/jpeglib.h53 symbols
libjpeg-turbo-sdk/src/main/jni/include/jpeglib.h53 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/simd/jsimd_x86_64.c51 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/simd/jsimd_i386.c51 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/doc/html/jquery.js42 symbols
libjpeg-turbo/src/main/jni/libjpeg-turbo/libjpeg-turbo-1.5.2/turbojpeg-jni.c39 symbols

For agents

$ claude mcp add Tiny \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact