Home

Awesome

McImage

Gitter

I will continue to update, please rest assured to use

中文文档

Android优雅的打包时自动化获取全部res资源

McImage is a Non-invasive plugin for compress all res in your project.

Include

Used algorithm

Release Success!

The version 1.0.1 now support all build.gradle version! Already support mavenCentral.

Feature

Update Log

The user use v0.0.2 update plugin need update your mctools dir together.

Who is using

I can put your icon with one link at here if you use McImage. My email b3069741@gmail.com

Use

The first, add the plugin in your project root build.gradle.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.smallsoho.mobcase:McImage:1.5.1'
    }
}

Then, apply the plugin in your every module.PS: If you have one more Module, you need apply it in every one.

apply plugin: 'McImage'

Last, put the mctools dir in your project root dir.Download it here

mctools

Config

You can set the config in build.gradle.If you not set this,all config will use default.

McImageConfig {
    isCheckSize true //Whether to detect image size,default true
    optimizeType "Compress" //Optimize Type,"ConvertWebp" or "Compress",default "Compress", "CompressWebp" is a better compression ratio but it don't support api < 18
    maxSize 1*1024*1024 //big image size threshold,default 1MB
    enableWhenDebug false //switch in debug build,default true
    isCheckPixels true // Whether to detect image pixels of width and height,default true
    maxWidth 1000 //default 1000
    maxHeight 1000 //default 1000
    whiteList = [ //do not do any optimization for the images who in the list 
              "icon_launcher.png"
    ]
    mctoolsDir "$rootDir"
    isSupportAlphaWebp false  //Whether support convert the Image with Alpha chanel to Webp,default false, the images with alpha chanels will be compressed.if config true, its need api level >=18 or do some compatible measures 
    multiThread true  //Whether open multi-thread processing,default true
    bigImageWhiteList = [] //do not detect big size or large pixels for the images who in the list
}

Thanks

pngquant

guetzli

cwebp

License

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.