Grunt task to optimize png and jpg images with optipng & jpegtran
npm install grunt-imggrunt-img
=============
[Grunt][grunt] task to optimize PNG and JPG images with [optipng][optipng] & [jpegtran][jpegtran] ([jpegtran-turbo][jpegtran-turbo] on win32).
First, be sure that you have [optipng][optipng] 0.7(or earlier) and [jpegtran][jpegtran] installed in your system.
shell
brew install optipng jpeg
`$3
Debian, Ubuntu and Mint
`shell
apt-get install optipng libjpeg libjpeg-progs
`
Both libraries are easy to find for RPM distributions too.$3
Don't worry because both libraries are included.$3
Install this task next to your project's [grunt.js gruntfile][getting_started] with:
`shell
npm install grunt-img
`Then add the line bellow to your project's
grunt.js gruntfile:`javascript
grunt.loadNpmTasks('grunt-img');
`
Questions? Take a look at this streamHow to config
Grunt provide a simple way to config its tasks, grunt-img follow the same principle:`js
grunt.initConfig({
img: { // using only dirs with output path
task1: {
src: 'public/src',
dest: 'public/img'
},
// recursive extension filter with output path
task2: {
src: ['public/src/*/.png'],
dest: 'public/img'
},
// file by file with output path
task3: {
src: ['public/src/logo.png','public/src/social.jpg'],
dest: 'public/img'
},
// single path to optimize and replace all images
task4: {
src: 'public/img'
},
// file by file to optimize and replace
task5: {
src: ['public/img/concert.jpg, public/img/halestorm.png']
},
// filter extension to optimize and replace
task6: {
src: ['public/img/*.png']
}
}
});
``MIT License
(c) Helder Santana
Credits
---------------
* HTML5 Boilerplate [node-build-script][node-build-script]
[node-build-script]: http://github.com/h5bp/node-build-script
[grunt]: https://github.com/cowboy/grunt
[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
[jpegtran]: http://jpegclub.org/jpegtran/
[jpegtran-turbo]: http://libjpeg-turbo.virtualgl.org/
[optipng]: http://optipng.sourceforge.net/
[homebrew]: http://mxcl.github.com/homebrew/