grunt-img

0.1.8 • Public • Published

grunt-img

Grunt task to optimize PNG and JPG images with optipng & jpegtran (jpegtran-turbo on win32).

Getting Started

First, be sure that you have optipng 0.7(or earlier) and jpegtran installed in your system.

for Mac users

You can install with homebrew

brew install optipng jpeg

for Linux users

Debian, Ubuntu and Mint

apt-get install optipng libjpeg libjpeg-progs

Both libraries are easy to find for RPM distributions too.

for Windows users

Don't worry because both libraries are included.

Setup task grunt-img with grunt.js

Install this task next to your project's grunt.js gruntfile with:

npm install grunt-img

Then add the line bellow to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-img');

Questions? Take a look at this stream

How to config

Grunt provide a simple way to config its tasks, grunt-img follow the same principle:

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']
        }
    }
});

License

MIT License (c) Helder Santana

Credits

Package Sidebar

Install

npm i grunt-img

Weekly Downloads

90

Version

0.1.8

License

none

Last publish

Collaborators

  • helder