• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

meili/WebpConvert_Gradle_Plugin

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

meili/WebpConvert_Gradle_Plugin

开源软件地址(OpenSource Url):

https://github.com/meili/WebpConvert_Gradle_Plugin

开源编程语言(OpenSource Language):

Groovy 100.0%

开源软件介绍(OpenSource Introduction):

webp batch convert pics gradle plugin

Read this in other languages: 简体中文.

###UpdateInfo

1.1.34

optimize the codes about print log

Introduce


This plugin can find the jpg,png files under the directory of /build/intermediates/res/${flavorName}/${buildType} while gradle building, and then auto convert them into webp files.

So,the generated apk is included with the webp pics.

The rule to find the target pic:

  1. the directories which name starts with 'drawable'
  2. the suffix name of the file is 'jpg' or 'png'
  3. exclude the .9 pic

The plugin task named webpConvertPlugin,which will execute before processXXXResource Task

Limit


Android support webp file naturly from 4.0 ,so you don't need to change your code if you minSdkVersion is 15+

But please pay attention,if your apk is using the jpg with transparency,then the convert webp file will not work below 4.2.1.

refer to :http://developer.android.com/guide/appendix/media-formats.html

pic

Install 'webp' command tools


  1. Install by homebrew :

    brew install webp
    
  2. install by macports:

    download the necessary pkg on http://distfiles.macports.org/MacPorts/ and install then run the command lines:

     export PATH=$PATH:/opt/local/bin
     sudo port selfupdate
     sudo port install webp
    
  3. use 'cwebp' command in terminal to check if it installed success.

reference to : https://developers.google.com/speed/webp/docs/precompiled#installing_cwebp_and_dwebp_on_os_x_with_macports

Usage:


  1. add below code in the outer build.gradle file(which is in the same directory of settings.gradle)

    classpath 'com.mogujie.gradle:webpConvertPlugin:1.1.34'

  2. add below code in the inner build.gradle file(which is in the same directory of src)

         apply plugin: 'webpConvert'
    
         webpinfo {
     	    //if skip the task when debug
     	    skipDebug = true
     	    //if print log
     	    isShowLog = false
         }
    
  3. add one file called 'webp_white_list.txt'(it will be created auto if the file don't exist when the plugin executed),it can keep the file you don't want to convert.just as below:

          bill_footer_sitepro_arrow.png
         cart_checkbox_false.png
    

now,clean your project then build it .you will find the webp pics is in your generated apk

gradle clean
gradle assembleDebug

Licence


webpConvertPlugin is licensed under the MIT license

contact me:[email protected]




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap