# grunt-contrib-imagemin

> Minify images

Latest version **4.0.0** (published 2020-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install grunt-contrib-imagemin
pnpm add grunt-contrib-imagemin
yarn add grunt-contrib-imagemin
bun add grunt-contrib-imagemin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2020-03-31 |
| First published | 2012-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 9 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1204 |
| Author | Grunt Team |
| Maintainers | cowboy, jmeas, kevva, shama, sindresorhus, tkellen, vladikoff, xhmikosr |
| Keywords | gruntplugin, compress, gif, image, img, jpeg, jpg, minify, png, svg |

## Links

- npm: https://www.npmjs.com/package/grunt-contrib-imagemin
- Repository: https://github.com/gruntjs/grunt-contrib-imagemin
- Homepage: https://github.com/gruntjs/grunt-contrib-imagemin#readme
- Issues: https://github.com/gruntjs/grunt-contrib-imagemin/issues
- npm.io page: https://npm.io/package/grunt-contrib-imagemin

## Dependencies (9)

- [plur](https://npm.io/package/plur.md) ^3.0.1
- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [p-map](https://npm.io/package/p-map.md) ^1.2.0
- [imagemin](https://npm.io/package/imagemin.md) ^6.0.0
- [pretty-bytes](https://npm.io/package/pretty-bytes.md) ^5.1.0
- [imagemin-svgo](https://npm.io/package/imagemin-svgo.md) ^7.0.0
- [imagemin-optipng](https://npm.io/package/imagemin-optipng.md) ^6.0.0
- [imagemin-gifsicle](https://npm.io/package/imagemin-gifsicle.md) ^6.0.1
- [imagemin-jpegtran](https://npm.io/package/imagemin-jpegtran.md) ^6.0.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2020-03-31
- 3.1.0 — 2018-11-06
- 3.0.0 — 2018-10-13
- 2.0.1 — 2017-06-23
- 2.0.0 — 2017-06-20
- 1.0.1 — 2016-05-23
- 1.0.0 — 2015-11-09
- 0.9.4 — 2015-03-22
- 0.9.3 — 2015-02-11
- 0.9.2 — 2014-11-11
- 0.9.1 — 2014-10-25
- 0.9.0 — 2014-10-22
- 0.8.1 — 2014-08-27
- 0.8.0 — 2014-08-11
- 0.7.2 — 2014-08-11
- … 17 more at https://npm.io/package/grunt-contrib-imagemin/versions

## README

# grunt-contrib-imagemin [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-imagemin.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-imagemin) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/7w491e6edsuanreu/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-contrib-imagemin/branch/master)

> Minify images using [imagemin](https://github.com/imagemin/imagemin)


## Install

```sh
npm install --save-dev grunt-contrib-imagemin
```


## Usage

```js
const mozjpeg = require('imagemin-mozjpeg');

grunt.initConfig({
    imagemin: {
        static: {
            options: {
                optimizationLevel: 3,
                svgoPlugins: [{removeViewBox: false}],
                use: [mozjpeg()] // Example plugin usage
            },
            files: {
                'dist/img.png': 'src/img.png',
                'dist/img.jpg': 'src/img.jpg',
                'dist/img.gif': 'src/img.gif'
            }
        },
        dynamic: {
            files: [{
                expand: true,
                cwd: 'src/',
                src: ['**/*.{png,jpg,gif}'],
                dest: 'dist/'
            }]
        }
    }
});

grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.registerTask('default', ['imagemin']);
```


## Options

### optimizationLevel *(png)*

* Type: `number`
* Default: `3`

Select optimization level between `0` and `7`.

> The optimization level 0 enables a set of optimization operations that require minimal effort. There will be no changes to image attributes like bit depth or color type, and no recompression of existing IDAT datastreams. The optimization level 1 enables a single IDAT compression trial. The trial chosen is what OptiPNG thinks it’s probably the most effective. The optimization levels 2 and higher enable multiple IDAT compression trials; the higher the level, the more trials.

Level and trials:

1. 1 trial
2. 8 trials
3. 16 trials
4. 24 trials
5. 48 trials
6. 120 trials
7. 240 trials

### progressive *(jpg)*

* Type: `boolean`
* Default: `true`

Lossless conversion to progressive.

### interlaced *(gif)*

* Type: `boolean`
* Default: `true`

Interlace gif for progressive rendering.

### svgoPlugins *(svg)*

Type: `Array`

Customize which SVGO plugins to use. [More here](https://github.com/sindresorhus/grunt-svgmin#available-optionsplugins).

### use

* Type: `Array`
* Default: `[imagemin.gifsicle(), imagemin.jpegtran(), imagemin.optipng(), imagemin.svgo()]`

[Plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use with imagemin. It comes bundled with the following **lossless** optimizers:

- [gifsicle](https://github.com/imagemin/imagemin-gifsicle) — *Compress GIF images*
- [jpegtran](https://github.com/imagemin/imagemin-jpegtran) — *Compress JPEG images*
- [optipng](https://github.com/imagemin/imagemin-optipng) — *Compress PNG images*
- [svgo](https://github.com/imagemin/imagemin-svgo) — *Compress SVG images*

These are bundled for convenience and most users will not need anything else.

### concurrency

* Type: `number`
* Default: `os.cpus().length`

Control the maximum number of image optimizations that may be performed in parallel.

## License

MIT © [Sindre Sorhus](https://sindresorhus.com)

---
_Source: https://npm.io/package/grunt-contrib-imagemin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
