node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Build Status Build status Coverage Status Dependency Status devDependency Status

Promise to detect the dimensions of an image file via HTTP(S), using image-size-stream

var httpImageSizePromise = require('http-image-size-promise');
.then(function(dimensions) {
  dimensions; //=> {width: 350, height: 150, type: 'gif'} 
.catch(function(reason) {


NPM version

Use npm.

npm install --save http-image-size-promise

Supported image formats

Check image-size-stream doc.


var httpImageSizePromise = require('http-image-size-promise');

httpImageSizePromise(imageFileUrl [, options])

imageFileUrl: String (URL) or Object (parsed URL object)
options: Object (directly passed to the got options and the image-size-stream option)
Return: Object (Promise)

It gets an image file via got module.

When it detects the width and height of the image, it will be fulfilled with an object in the form {width: [Number], height: [Number], type: [String]} as an argument of callback.

type will be one of the following strings: bmp gif jpg png psd svg tiff webp

When it fails to get the file or the file is not supported, it will be rejected with an error as an argument of callback.

var imageSize = httpImageSizePromise();
var onFulfilled = function(dimensions) {
  console.log('Size: ' + dimensions.width + ' x ' + dimensions.height);
  console.log('Type: ' + dimensions.type);
var onRejected = function(reason) {
imageSize('').then(onFulfilled, onRejected);


Copyright (c) 2014 Shinnosuke Watanabe

Licensed under the MIT LIcense.