lib/image-size.js
function getImageSizeFromFile(file) {
	return new Promise((resolve, reject) => {
		const isDataUrl = file.match(/^data:.+?;base64,/);

		if (isDataUrl) {
			// NB should use sync version of `sizeOf()` for buffers
			try {
				const data = Buffer.from(file.slice(isDataUrl[0].length), 'base64');
				return resolve(sizeForFileName('', sizeOf(data)));
			} catch (err) {
				return reject(err);
			}
		}

		sizeOf(file, (err, size) => {
			if (err) {
				reject(err);
			} else {
				resolve(sizeForFileName(path.basename(file), size));
			}
		});
	});
}
function getImageSizeFromFile(file) {
	return new Promise((resolve, reject) => {
		const isDataUrl = file.match(/^data:.+?;base64,/);

		if (isDataUrl) {
			// NB should use sync version of `sizeOf()` for buffers
			try {
				const data = Buffer.from(file.slice(isDataUrl[0].length), 'base64');
				return resolve(sizeForFileName('', sizeOf(data)));
			} catch (err) {
				return reject(err);
			}
		}

		sizeOf(file, (err, size) => {
			if (err) {
				reject(err);
			} else {
				resolve(sizeForFileName(path.basename(file), size));
			}
		});
	});
}
function getImageSizeFromFile ( file ) { return new Promise ( ( resolve , reject ) => { const isDataUrl = file . match ( / ^data:.+?;base64, / ) ; if ( isDataUrl ) { // NB should use sync version of `sizeOf()` for buffers try { const data = Buffer . from ( file . slice ( isDataUrl [ 0 ] . length ) , 'base64' ) ; return resolve ( sizeForFileName ( '' , sizeOf ( data ) ) ) ; } catch ( err ) { return reject ( err ) ; } } sizeOf ( file , ( err , size ) => { if ( err ) { reject ( err ) ; } else { resolve ( sizeForFileName ( path . basename ( file ) , size ) ) ; } } ) ; } ) ; }
Get image size from file on local file system
@param  {String} file
@return {Promise}
Get image size from file on local file system