grunt-punypng
v0.1.5
Published
optimize images with punypng.
Downloads
4
Maintainers
Readme
grunt-punypng
optimize images with punypng.
Getting Started
This plugin requires Grunt ~0.4.4
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-punypng --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-punypng');
The "punypng" task
Overview
In your project's Gruntfile, add a section named punypng
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
punypng: {
options: {
limit: 20,
key: 'cd1e2670d3167db696ea56b8ck965fd3620a579cb'
},
test: {
files: [{
src: 'test/fixtures/*.png',
dest: 'test/expected/'
}]
}
},
});
Options
options.key
Type: key
用于识别punypng账户的key,注册punypny账户后可以获得(http://www.punypng.com/profile)
options.lossy
Type: lossy
Default value: 'true'
是否使用有损的压缩方式。推荐使用有损的压缩方式,有损的压缩是punypng的核心优势
options.rename
Type: lossy
Default value: 'true'
当lossy为true,重命名文件,去掉文件名中的".indexed"字符串;例如:banana.indexed.png 重命名为 banana.png。
options.limit
Type: limit
指定并发请求图片的数量。
Usage Examples
Default Options
grunt.initConfig({
punypng: {
options: {
// 使用无损的压缩
lossy: false,
limit: 20,
key: 'cd1e2670d3167db696ea56b8c965fd3620a579cb'
},
test: {
files: [{
src: 'test/fixtures/*.png',
dest: 'test/expected/'
}]
}
},
});