npm.io
1.0.1 • Published 12 years agoCLI

image-dimensions-browserify

Licence
MIT
Version
1.0.1
Deps
2
Vulns
0
Weekly
0

image-dimensions-browserify

Have you ever needed to add an onLoad handler to an image so that your JavaScript can be aware of the image dimensions?

Did that feel silly because the image was right there in the repository and your CSS preprocessor could already do the same?

Given:

var imageWidth = getImageWidth('some-picture.jpg');
var imageHeight = getImageHeight('some-picture.png');
var imageDimensions = getImageDimensions('some-picture.svg');

Result:

var imageWidth = 800;
var imageHeight = 600;
var imageDimensions = {width: 800, height: 600};

Keywords