image-dimensions-loader

0.1.0 • Public • Published

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}

Readme

Keywords

none

Package Sidebar

Install

npm i image-dimensions-loader

Weekly Downloads

33

Version

0.1.0

License

Apache-2.0

Last publish

Collaborators

  • tremby