JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 292255
  • Score
    100M100P100Q161641F
  • License MIT

Image minimizing loader for webpack

Package Exports

  • img-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (img-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

img-loader

Image minimizing loader for webpack, meant to be used with url-loader or file-loader

Minify PNG, JPEG, GIF and SVG images with imagemin

Issues with the minimized output should be reported to imagemin.

Install

$ npm install img-loader --save-dev

Usage

Documentation: Using loaders

var url = require('file!img!./file.png');

By default the minification is run when webpack is run in production mode

Options

  • [minimize] - Minify regardless of webpack mode.
  • [optimizationLevel] Select an optipng optimization level between 0 and 7.
  • [progressive] Convert to jpg and gif to progressive.

Examples

require('img?optimizationLevel=5');
require('img?progressive=true');
require('img?minimize&optimizationLevel=5&progressive=true');
loaders: [
  { test: /\.(jpe?g|png|gif|svg)$/i, loaders: [ 'url?limit=10000', 'img?minimize' ] }
]

Imagemin comes bundled with the following optimizers:

optimizationLevel (png)

Type: number
Default: 3

Select an 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, gif)

Type: boolean
Default: false

Enable jpegtran progressive lossless conversion to progressive. Enable gifsicle interlace for progressive rendering.

License

This software is free to use under the MIT license. See the LICENSE-MIT file for license text and copyright information.