Giter VIP home page Giter VIP logo

androidwebp-gradleplugin's Introduction

AndroidWebP-GradlePlugin

一款支持自动将图片转换成WebP格式的Android构建插件

功能:

  1. 支持将资源文件夹中的jpg、png图片转换成webp格式;
  2. 构建过程中自动下载libwebp,无需再配置环境;
  3. 支持手动与自动两种构建模式,祥见 配置
  4. 自动构建过程中,图片转换时机位于mergeResources之前,避免图片被重复处理多次;

接入:

  1. 引用插件

    buildscript {
        repositories {
            maven {
                url 'https://dl.bintray.com/zh8637688/maven/'
            }
        }
        dependencies {
            classpath 'cz.gradle.android:webp:0.0.1'
        }
    }
    
  2. 应用plugin

    apply plugin: 'cz.webp'
    
  3. 配置

    WebPAndroid {
        autoConvert true
        quality 75
    }
    
  4. 构建

    autoConvert = true:         ./gradlew build
    
    autoConvert = false:        ./gradlew convert***WebP
    

配置:

配置名称 类型 默认值 说明
quality int 75 指定转换过程中RGB通道的压缩因,取值范围0到100。值越小,压缩率越高,图片质量越低。
autoConvert boolean false 若设置为true,转换任务将自动加入构建过程,执行gradle build即可;若设置为false,需手动执行gradle convertWebP。

构建产物:

  • autoConvert = true,sourSets.res指定资源文件夹中所有jpg、png(非.9)图片将被转换为webp格式,原有图片将移动到projectDir/ori_res目录中。
  • autoConvert = false,原有图片路径不改变,转换后的webp图片位于projectDir/webp目录中。

TODO:

自动模式下暂不支持增量构建(convertWebP任务的输出会改变输入属性。将输出路径设置在build目录下,并在其他任务中屏蔽原先的图片即可)

androidwebp-gradleplugin's People

Contributors

zh8637688 avatar

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.