All Projects → android-notes → TinyPngPlugin

android-notes / TinyPngPlugin

Licence: other
android tiny png plugin

Programming Languages

groovy
2714 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to TinyPngPlugin

react-native-compressor
The lightweight library for compress image, video, and audio with an awesome experience
Stars: ✭ 157 (+582.61%)
Mutual labels:  compress-images
gulp-tinypng-compress
TinyPNG API wrapper for compressing PNG & JPG images
Stars: ✭ 49 (+113.04%)
Mutual labels:  compress-images
imagezero
Fast Lossless Color Image Compression Library
Stars: ✭ 49 (+113.04%)
Mutual labels:  compress-images
TinyPngPlugin
TinyPng gradle plugin for android
Stars: ✭ 240 (+943.48%)
Mutual labels:  compress-images
Imgbot
An Azure Function solution to crawl through all of your image files in GitHub and losslessly compress them. This will make the file size go down, but leave the dimensions and quality untouched. Once it's done, ImgBot will open a pull request for you to review and merge. [email protected]
Stars: ✭ 1,017 (+4321.74%)
Mutual labels:  compress-images
Compressor
An android image compression library.
Stars: ✭ 6,745 (+29226.09%)
Mutual labels:  compress-images
Gulp Imagemin
Minify PNG, JPEG, GIF and SVG images
Stars: ✭ 1,860 (+7986.96%)
Mutual labels:  compress-images
Localresizeimg
🔥 前端本地客户端压缩图片,兼容IOS,Android,PC、自动按需加载文件
Stars: ✭ 3,135 (+13530.43%)
Mutual labels:  compress-images
subjectiveqe-esrgan
PyTorch implementation of ESRGAN (ECCVW 2018) for compressed image subjective quality enhancement.
Stars: ✭ 12 (-47.83%)
Mutual labels:  compress-images

TinyPng Plugin

TinyPngPlugin是一个Android Gradle插件,可以批量压缩项目中的图片

  • 兼容Android Gradle Plugin 2.x-3.x
  • 自动识别sourceSets,无需为tinypng plugin配置资源路径
  • 可配置若干api key,压缩失败自动更换api key,避免每月500上限
  • 可配置图片白名单
  • 可配置压缩失败时是否终止Task
  • 默认不压缩9.png图片
  • 同名替换文件,新增文件都会压缩

使用方式

  • 在工程根目录中的build.gradle文件中的 buildscript.dependencies中添加classpath "com.wanjian.plugin:tinypng:0.0.6" 例如:
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath "com.wanjian.plugin:tinypng:0.0.6"
    }
}

  • 在各module的build.gradle文件添加apply plugin: "com.wanjian.tinypng",同时在该文件中配置如下。

enable控制该module是否开启图片压缩。

abortOnError控制压缩失败时是否终止Task。

skip9Png是否不压缩 9.png图片,默认不压缩。tinypng压缩的9.png图片可能导致打包失败

appendCompressRecord是否在compressed_pictures文件中追加压缩后的图片的MD5值。默认false。false:当productFlavors中配置的资源路径不同时,编译不同的flavor时,压缩的图片的md5值会相互覆盖。true:只追加记录,不删除

keys配置压缩图片需要的tiny png api key,每个key每月最多可以压缩500张图片。 可以去这Tiny Developers Page 申请key,每个key需要一个邮箱,可是使用临时邮箱

tinyPng {
    //http://www.bccto.me/  临时邮箱申请key
    //把下面的keys换成你申请的key,建议多配置几个
    enable true
    abortOnError false
    skip9Png true
    appendCompressRecord false
    keys = ["FBYz4WZR5tj9S4Jv4tCL5m3KgrQnXBgP",
            "1sQXBgXvvhfx5j1l10DKRvVvrlD3rcS4",
            "DdMZxbJ7W9K15hSZ6G5QVNbqh7PKGxjX",
            "xS2CNP0w7Sp4Xz7P1DvcCZNsQ9QJNsyb",
            "X7z8kgM3zw1Fr3R8RQTkhN3Kynx8xpdX",
            "mT1td5Qt6JW7yy0n2pkJd6ZwBxmHsjBy",
            "ctW1PG2wJhpJYxDhcj4NSgQ14WFxC7gb",
            "SWxfXRhZ6H1wnXnd3j5HmbK8wCpvdH0X",
    ]
}

  • 可以在各module下添exclude_pictures.txt文件,资源根目录下的drawable-xx文件夹及mipmap文件夹中的图片路径(以该module作为根路径)包含该文件配置的路径的图片不会压缩
  • 也可以手动调用 ./grawablew tinyPngxxx 压缩图片
  • 各module下的compressed_pictures文件是tinypng plugin自动生成的,不要手动修改里面的内容,该module中压缩后的图片的md5值都记录在这里面
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].