image-dimensions-loader
v0.1.0
Published
Image dimensions loader module for Webpack
Downloads
504
Readme
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
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}