Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

probe-image-size

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

probe-image-size - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

lib/parse_stream/bmp.js

8

CHANGELOG.md

@@ -0,1 +1,9 @@

1.1.0 / 2016-05-25
------------------
- Added promise support.
- Use `readable-stream` instead of `stream`.
- Reorganised internal files structure & tests.
1.0.6 / 2016-04-13

@@ -2,0 +10,0 @@ ------------------

20

lib/common.js
'use strict';
var Transform = require('stream').Transform;
var Transform = require('readable-stream').Transform;
var streamParser = require('stream-parser');

@@ -29,1 +29,19 @@ var inherits = require('util').inherits;

};
exports.sliceEq = function (src, start, dest) {
for (var i = start, j = 0; j < dest.length;) {
if (src[i++] !== dest[j++]) return false;
}
return true;
};
exports.str2arr = function (str) {
var arr = new Array(str.length);
for (var i = 0; i < arr.length; i++) {
/* eslint-disable no-bitwise */
arr[i] = str.charCodeAt(i) & 0xFF;
}
return arr;
};

43

lib/index.js

@@ -11,9 +11,9 @@

var parsers = {
bmp: require('./parsers/bmp'),
gif: require('./parsers/gif'),
jpeg: require('./parsers/jpeg'),
png: require('./parsers/png'),
psd: require('./parsers/psd'),
tiff: require('./parsers/tiff'),
webp: require('./parsers/webp')
bmp: require('./parse_stream/bmp'),
gif: require('./parse_stream/gif'),
jpeg: require('./parse_stream/jpeg'),
png: require('./parse_stream/png'),
psd: require('./parse_stream/psd'),
tiff: require('./parse_stream/tiff'),
webp: require('./parse_stream/webp')
};

@@ -70,4 +70,3 @@

/* eslint-disable eqeqeq */
if (length == +length) {
if (length && length.match(/^\d+$/)) {
result.length = +length;

@@ -94,14 +93,36 @@ }

// Cache for promise implementation
var P;
///////////////////////////////////////////////////////////////////////
// Exports
//
/* eslint-disable consistent-return */
module.exports = function get_image_size(src, callback) {
var prober;
if (typeof src.on === 'function' && typeof src.emit === 'function') {
// looks like an EventEmitter, treating it as a stream
probeStream(src, callback);
prober = probeStream;
} else {
probeHttp(src, callback);
prober = probeHttp;
}
if (!callback) {
P = P || require('any-promise');
return new P(function (resolve, reject) {
prober(src, function (err, data) {
if (err) reject(err);
else resolve(data);
});
});
}
prober(src, callback);
};
module.exports.parsers = parsers;
{
"name": "probe-image-size",
"version": "1.0.6",
"version": "1.1.0",
"description": "Get image size without full download (JPG, GIF, PNG, WebP, BMP, TIFF, PSD)",

@@ -27,3 +27,5 @@ "keywords": [

"dependencies": {
"any-promise": "^1.3.0",
"async": "^1.4.2",
"readable-stream": "^2.1.4",
"request": "^2.60.0",

@@ -30,0 +32,0 @@ "stream-parser": "~0.3.1"

@@ -36,2 +36,8 @@ probe-image-size

// With Promise
//
probe('http://example.com/image.jpg').then(function (result) {
console.log(result); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg' }
});
// From the stream

@@ -54,3 +60,3 @@ //

### probe(src, callback(err, result))
### probe(src [, callback(err, result)])

@@ -81,2 +87,4 @@ `src` can be of this types:

If callback not provided, `Promise` will be returned.
__Note.__ If you use stream as source, it's your responsibility to terminate

@@ -83,0 +91,0 @@ reading in callback. That will release resources as soon as possible. On

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc