Git Product home page Git Product logo

webpconvert_gradle_plugin's 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]

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.