Skip to content

Commit

Permalink
更新0.0.4 readme
Browse files Browse the repository at this point in the history
  • Loading branch information
owenlongbo committed Jul 31, 2017
1 parent 9acef30 commit 2f38c17
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 26 deletions.
40 changes: 31 additions & 9 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@

[Mc插件原理解析](http://smallsoho.com/android/2017/04/07/McImage%E6%8F%92%E4%BB%B6%E8%A7%A3%E6%9E%90/)

McImage是一个插件帮助你检查你res中的大图和全量压缩你的res并对所有图选择性转换成webp(最大化收益情况)
McImage是无侵入式的全量压缩资源图片插件

包括

- Jar包中的图
- AAR中的图
- 子Module中的图

插件使用[pngquant](https://github.com/pornel/pngquant)算法进行压缩,每张图能节省百分之70%的大小
插件使用算法

- [pngquant](https://github.com/pornel/pngquant)算法压缩png
- [guetzli](https://github.com/google/guetzli)算法压缩jpg
- [cwebp](https://developers.google.com/speed/webp/)算法转换webp

### Future

- 全量压缩png和jpg图片,每张图能节省百分之70大小
- 最大化收益下对图片进行webp转换 (after v0.0.3 support)
- 插件自动化匹配当前操作系统,包括Linux,Mac,Windows (after v0.0.4 support)
- 插件接入简单,无感知,仅要一行代码

### Update Log

> v0.0.2的用户更新到0.0.3需要升级你的mctools文件夹,已经上传到release。
> v0.0.2以后的用户更新到0.0.2以上需要升级你的mctools文件夹,已经上传到release。
- 0.0.4 : 添加了自动识别操作系统的支持,去掉了webpQuality选项(设置不好对图片压缩会肉眼可见,强制使用默认值),优化了Log写法
- 0.0.3 : 添加了对webp的支持。会在压缩之后自动将你符合规则的图片转换为webp格式,并且会比对大小,如果转换之后更大则舍弃转换,并且插件对API 14 和API 18的webp问题进行了处理,具体问题请google查询。
- 0.0.2 : 完善了日志的输出

Expand All @@ -29,12 +41,12 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.smallsoho.mobcase:McImage:0.0.3'
classpath 'com.smallsoho.mobcase:McImage:0.0.4'
}
}
```

然后在你想要压缩的Module的build.gradle中应用这个插件
然后在你想要压缩的Module的build.gradle中应用这个插件,注意如果你有多个Module,请在每个Module的build.gradle文件中apply插件

```groovy
apply plugin: 'McImage'
Expand All @@ -46,19 +58,16 @@ apply plugin: 'McImage'
mctools
```

PS:插件默认执行平台是MAC OSX,若果你想要在别的平台上使用,清手动替换mctools中的pngquant文件,文件在[pngquant](https://github.com/pornel/pngquant)库中可以找到

### Config

你可以在build.gradle中配置插件的几个属性
你可以在build.gradle中配置插件的几个属性,如果不设置,所有的属性都使用默认值

```groovy
McImageConfig {
isCheck true //default true 是否进行图片大小超标的检查
isCompress true //default true 是否进行图片压缩
maxSize 1*1024*1024 //default 1MB 图片大小超标的标准大小
isWebpConvert true //default true 是否进行对图片的webp处理
webpQuality 75 //default 75 对图片进行webp处理的质量
isJPGConvert true //default true 是否对jpg进行webp处理
enableWhenDebug true //default true 是否在debug的时候启用插件
}
Expand All @@ -67,7 +76,20 @@ McImageConfig {
### Thanks

[pngquant](https://github.com/pornel/pngquant)
[guetzli](https://github.com/google/guetzli)
[cwebp](https://developers.google.com/speed/webp/)

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.
55 changes: 38 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,74 @@
# McImage

[中文文档](README-CN.md)

[Mc插件原理解析](http://smallsoho.com/android/2017/04/07/McImage%E6%8F%92%E4%BB%B6%E8%A7%A3%E6%9E%90/)

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 and choose img to format to webp (Maximize earnings).
McImage is a Non-invasive plugin for compress all res in your project.

Include

- The Image in Jar res
- The Image in aar res
- The Image in Module res
- The img in Jar
- The img in AAR
- The img in Module

Used algorithm

- [pngquant](https://github.com/pornel/pngquant) compress png
- [guetzli](https://github.com/google/guetzli) compress jpg
- [cwebp](https://developers.google.com/speed/webp/) compress webp

The Plugin use [pngquant](https://github.com/pornel/pngquant) to compress image,it can save 70% size.
### Future

- Compress all png and jpg, every img can save %70 size.
- As far as possible to convert img to webp (after v0.0.3 support)
- Auto match the system which you build your project.Include Linux,Mac OS X and Windows (after v0.0.4 support)
- Use this plugin only need one line code.

### Update Log

> The user of v0.0.2 need update your mctools dir.
> The user use v0.0.2 update plugin need update your mctools dir together.
- 0.0.4 : Add auto choose system future.Remove webpQualitu config (Set inappropriate will result the img lossless)
- 0.0.3 : Add webp ! It will auto convert your png (without alpha in min API < 18 and not work in min API < 14) and jpg to webp if it will become more small.
- 0.0.2 : Improve the log.

### Use

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

```groovy
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.smallsoho.mobcase:McImage:0.0.3'
classpath 'com.smallsoho.mobcase:McImage:0.0.4'
}
}
```

Then, apply this plugin in the module build.gradle which you want to compress.
Then, apply the plugin in your every module.PS: If your have one more Module, you need apply it in every one.

```groovy
apply plugin: 'McImage'
```

Last, put the dir in your project root.Download from [here](https://github.com/Mobcase/McImage/releases)
Last, put the mctools dir in your project root dir.Download it [here](https://github.com/Mobcase/McImage/releases)


```
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.
You can set the config in build.gradle.If you not set this,all config will use default.

```groovy
McImageConfig {
isCheck true //default true
isCompress true //default true
maxSize 1*1024*1024 //default 1MB
maxSize 1*1024*1024 //default 1MB
isWebpConvert true //default true
webpQuality 75 //default 75
isJPGConvert true //default true
enableWhenDebug true //default true
}
Expand All @@ -69,7 +77,20 @@ McImageConfig {
### Thanks

[pngquant](https://github.com/pornel/pngquant)
[guetzli](https://github.com/google/guetzli)
[cwebp](https://developers.google.com/speed/webp/)

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.

0 comments on commit 2f38c17

Please sign in to comment.