使用 McImage 极致压缩 apk 中图片百分之 70 大小

2,524

中文文档

McImage is an Android Gradle Plugin.It can help you check the big image in your res and compress your all image in your res.

Include

  • The Image in Jar res
  • The Image in aar res
  • The Image in Module res

The Plugin use pngquant to compress image,it can save 70% size.

Use

First,change your root build.gradle.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.smallsoho.mobcase:McImage:0.0.1'
    }
}

Then, apply this plugin in the module build.gradle which you want to compress.

apply plugin: 'McImage'

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

mctools

PS: the plugin is default in MAC OSX, if you want to use in other platform,please change the pngquant bintray in mctools.

Config

You can config the plugin in the build.gradle you apply this plugin.Include isCheck,isCompress and the max size of check.

McImageConfig {
  isCheck true //default true
  isCompress true //default true
  maxSize 1*1024*1024 //default 1MB 
}

Thanks

pngquant