Socket
Socket
Sign inDemoInstall

image-size

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-size - npm Package Compare versions

Comparing version 0.0.5 to 0.0.16

.jshintrc

43

lib/detector.js

@@ -1,35 +0,20 @@

module.exports = function (buffer) {
var typeMap = {};
var types = require('./types');
var char2 = buffer.toString('ascii', 0, 2);
if ('BM' === char2) {
return 'bmp';
}
// load all available handlers
types.forEach(function (type) {
typeMap[type] = require('./types/' + type).detect;
});
var char4 = buffer.toString('ascii', 0, 4);
if ('8BPS' === char4) {
return 'psd';
}
module.exports = function (buffer, filepath) {
var char6 = buffer.toString('ascii', 0, 6);
if (/^GIF8[7,9]a/.test(char6)) {
return 'gif';
}
var type, result;
buffer = buffer.slice(0, 16);
var char8 = buffer.toString('ascii', 0, 8);
if ('\tPNG\r\n\u001a\n' === char8) {
if ('IHDR' !== buffer.toString('ascii', 12, 16)) {
throw new TypeError('invalid png');
for (type in typeMap) {
result = typeMap[type](buffer, filepath);
if (result) {
return type;
}
return 'png';
}
var hex2 = buffer.toString('hex', 0, 2);
if ('ffd8' === hex2) {
return 'jpg';
}
var hex4 = buffer.toString('hex', 0, 4);
if ('49492a00' === hex4 || '4d4d002a' === hex4) {
return 'tiff';
}
};
};
{
"name": "image-size",
"version": "0.0.5",
"version": "0.0.16",
"description": "get dimensions of any image file",
"main": "index.js",
"main": "lib/index.js",
"engines": {
"node": ">=0.8.0"
},
"bin": {

@@ -18,3 +21,14 @@ "image-size": "./bin/image-size"

"image",
"dimensions"
"size",
"dimensions",
"resolution",
"width",
"height",
"png",
"jpeg",
"bmp",
"gif",
"psd",
"tiff",
"webp"
],

@@ -27,5 +41,9 @@ "author": "netroy <aditya@netroy.in> (http://netroy.in/)",

"devDependencies": {
"mocha": "~1.12.0",
"expect.js": "~0.2.0"
"escomplex-js": "~0.1.0",
"expect.js": "~0.2.0",
"glob": "~3.2.7",
"jshint": "~2.3.0",
"mocha": "~1.14.0",
"sinon": "~1.7.3"
}
}

@@ -1,7 +0,4 @@

#### Work in progress
node module to detect dimentions of various supported image formats
[![NPM version](https://badge.fury.io/js/image-size.png)](https://npmjs.org/package/image-size)
[![Build Status](https://travis-ci.org/netroy/image-size.png?branch=master)](https://travis-ci.org/netroy/image-size)
[![Dependency Status](https://gemnasium.com/netroy/image-size.png)](https://gemnasium.com/netroy/image-size)
[![Technical debt analysis](https://www.sidekickjs.com/r/netroy/image-size/status_badge.svg)](https://www.sidekickjs.com/r/netroy/image-size)

@@ -16,19 +13,31 @@ #### Instalation

var sizeOf = require('image-size');
var dimesions = sizeOf('images/funny-cats.png');
console.log(dimesions.width, dimesions.height);
var dimensions = sizeOf('images/funny-cats.png');
console.log(dimensions.width, dimensions.height);
```
##### Async version
```javascript
var sizeOf = require('image-size');
sizeOf('images/funny-cats.png', function (err, dimensions) {
console.log(dimensions.width, dimensions.height);
});
```
#### Supported formats
* BMP
* GIF
* JPEG
* PNG
* GIF
* BMP
* PSD
* TIFF
##### Upcoming
* JPEG
* WebP
* TIFF
* PSD
* SVG
* SWF
##### Credits
not a direct port, but an attempt to have something like
[dabble's imagesize](https://github.com/dabble/imagesize/blob/master/lib/image_size.rb) as a node module.
[dabble's imagesize](https://github.com/dabble/imagesize/blob/master/lib/image_size.rb) as a node module.
##### [Contributors](Contributors.md)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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