Git Product home page Git Product logo

advancedluban's Introduction

AdvancedLuban

build license

中文版

AdvancedLuban —— Is a convenient simple Android image compression tool library.Provides multiple compression strategies.Different calling methods,Custom compression,Multi-Image synchronous compression and so on,Focus on a better picture compression experience

Image Count Origin Total size Compressed Total size Time Cost
1 4.3Mb 85Kb 0.23s
4 14.22Mb 364Kb 1.38s
9 36.23Mb 745Kb 4.43s

Import

Maven

<dependency>
  <groupId>me.shaohui.advancedluban</groupId>
  <artifactId>library</artifactId>
  <version>1.1.3</version>
  <type>pom</type>
</dependency>

or Gradle

compile 'me.shaohui.advancedluban:library:1.1.3'

Usage

Listenermode

Advanced Luban internal Computation thread for image compression, external calls simply set the Listener can be:

Luban.get(this)                     // initialization of Luban
    .load(File)                     // set the image file to compress
    .putGear(Luban.THIRD_GEAR)      // set the compress mode, default is : THIRD_GEAR
    .launch(listener);              // start compression and set the listener

RxJava方式

RxJava call the same default Computation thread to compress, you can also define any thread, can be observed in any thread:

Luban.get(this)                                     
        .load(file)                               
        .putGear(Luban.CUSTOM_GEAR)                 
        .asObservable()                             // generate Observable
        .subscribe(successAction, errorAction)      // subscribe the compress result

Compression mode

1. CUSTOM_GEAR

compress image file according to the restrictions you set, you can limit: the width, height or file size of the image file

    Luban.get(this)
            .load(mFile)
            .setMaxSize(500)                // limit the final image size(unit:Kb)
            .setMaxHeight(1920)             // limit image height
            .setMaxWidth(1080)              // limit image width
            .putGear(Luban.CUSTOM_GEAR)     // use CUSTOM GEAR compression mode
            .asObservable()

2. THIRD_GEAR

Using custom algorithms, according to the picture aspect ratio, the picture is compressed quickly, the resulting image size is about 100Kb, for general compression, no file size limit and picture width limit

3. FIRST_GEAR

The simplified version of THIRD GEAR, the compressed image resolution is less than 1280 x 720, the final file is less than 60Kb. suitable for fast compression, regardless of the final picture quality

Multi-Image synchronous compression

If you choose to call the way Listener:

    Luban.get(this)
            .putGear(Luban.CUSTOM_GEAR)             
            .load(fileList)                     // load all images
            .launch(multiCompressListener);     // passing an OnMultiCompress Listener

or the RxJava way to use:

    Luban.get(this)
            .putGear(Luban.CUSTOM_GEAR)             
            .load(fileList)                     // load all images
            .asListObservable()                 // Generates Observable <List<File>. Returns the result of all the images compressed successfully

Issue

You can according to your needs to choose a different compression mode and call mode ! b( ̄▽ ̄)d !Finally, I welcome the Issue

Thanks For

License

Copyright 2016 shaohui10086

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.

advancedluban's People

Watchers

James Cloos avatar Hi!k avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.