0.1.0 • Published 6 years ago

image-dimensions-loader v0.1.0

Weekly downloads
67
License
Apache-2.0
Repository
github
Last release
6 years ago

Image dimensions loader for Webpack

A webpack loader which retrieves the dimensions of the image.

This loader does not emit the file itself; it only gives you an object with information about the file. If you also want the file emitted, see the project this was forked from.

Usage

Documentation: Using loaders

npm install image-dimensions-loader --save

var image = require("image-dimensions!./file.png");
// => returns an object
// => { width: 150, height: 50, type: "png", bytes: 1234 }

Examples

webpack.config.js

// webpack.config.js
module.exports = {
  output: {
    publicPath: '/public/'
  },
  module: {
    loaders: [
      {
        test: /\.(gif|jpeg|jpg|png|svg)$/,
        loader: 'image-dimensions'
      }
    ]
  }
};

example_module.js

var result = require("./image.png");
// => {width: 500, height: 700, type: "png", bytes: 1234}