grunt-tinify-image
v0.1.9
Published
Compression for PNG and JPG files using the remote service from tinypng.com / tinyjpeg.com
Downloads
2
Maintainers
Readme
grunt-tinify
Compression for PNG and JPG files using the remote service from tinypng.com / tinyjpeg.com
Getting Started
This plugin requires Grunt ~0.4.5
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-tinify --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-tinify');
Get TinyPng API KEY
please go to tinyPNG website and register an API key.
The "tinify" task
Overview
In your project's Gruntfile, add a section named tinify
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
tinify: {
options: {
key: 'YOUR_TINYPNG_API_KEY',
tmpfile: 'tmp.file'
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
Options
options.key
Type: String
Default value: ' '
A string value that is your tinyPNG key.
options.tmpfile
Type: String
Default value: 'record.json'
In order for better performance, tinify need a place to save each image files' hash key. A string value that is used to save hash value.
Usage Examples
Default Options
In this example, the default options are used to compress images in place.
grunt.initConfig({
tinify: {
options: {
key: 'YOUR_TINYPNG_API_KEY',
},
files: {
src: ['_public/**/*.png', '_public/**/*.jpg'],
},
},
});
Custom Options
In this example, custom options are used to compress images in other directory.
grunt.initConfig({
tinify: {
options: {
key: 'YOUR_TINYPNG_API_KEY',
tmpfile: 'tmp.file'
},
files: {
src: ['_public/**/*.png', '_public/**/*.jpg'],
dest: 'output/'
},
},
});
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
0.1.0 Initial Version