probe-image-size
Advanced tools
Comparing version 1.2.1 to 2.0.0
@@ -0,1 +1,9 @@ | ||
2.0.0 / 2016-06-25 | ||
------------------ | ||
- SVG support | ||
- width/height now can be float (with fractional part) | ||
- Return dimention units ('px' everywhere except SVG) | ||
1.2.1 / 2016-05-30 | ||
@@ -2,0 +10,0 @@ ------------------ |
@@ -29,3 +29,5 @@ 'use strict'; | ||
type: 'bmp', | ||
mime: 'image/bmp' | ||
mime: 'image/bmp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -32,0 +34,0 @@ }); |
@@ -30,3 +30,5 @@ 'use strict'; | ||
type: 'gif', | ||
mime: 'image/gif' | ||
mime: 'image/gif', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -33,0 +35,0 @@ }); |
@@ -71,3 +71,5 @@ 'use strict'; | ||
type: 'jpg', | ||
mime: 'image/jpeg' | ||
mime: 'image/jpeg', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -74,0 +76,0 @@ }); |
@@ -37,3 +37,5 @@ 'use strict'; | ||
type: 'png', | ||
mime: 'image/png' | ||
mime: 'image/png', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -40,0 +42,0 @@ }); |
@@ -31,3 +31,5 @@ 'use strict'; | ||
type: 'psd', | ||
mime: 'image/vnd.adobe.photoshop' | ||
mime: 'image/vnd.adobe.photoshop', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -34,0 +36,0 @@ }); |
@@ -103,3 +103,5 @@ 'use strict'; | ||
type: 'tiff', | ||
mime: 'image/tiff' | ||
mime: 'image/tiff', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -106,0 +108,0 @@ } |
@@ -29,3 +29,5 @@ 'use strict'; | ||
type: 'webp', | ||
mime: 'image/webp' | ||
mime: 'image/webp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -52,3 +54,5 @@ }); | ||
type: 'webp', | ||
mime: 'image/webp' | ||
mime: 'image/webp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -69,3 +73,5 @@ }); | ||
type: 'webp', | ||
mime: 'image/webp' | ||
mime: 'image/webp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}); | ||
@@ -72,0 +78,0 @@ }); |
@@ -15,5 +15,3 @@ 'use strict'; | ||
if (!sliceEq(data, 0, SIG_BM)) { | ||
return; | ||
} | ||
if (!sliceEq(data, 0, SIG_BM)) return; | ||
@@ -24,4 +22,6 @@ return { | ||
type: 'bmp', | ||
mime: 'image/bmp' | ||
mime: 'image/bmp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
}; |
@@ -17,5 +17,3 @@ 'use strict'; | ||
if (!sliceEq(data, 0, SIG_GIF87a) && !sliceEq(data, 0, SIG_GIF89a)) { | ||
return; | ||
} | ||
if (!sliceEq(data, 0, SIG_GIF87a) && !sliceEq(data, 0, SIG_GIF89a)) return; | ||
@@ -26,4 +24,6 @@ return { | ||
type: 'gif', | ||
mime: 'image/gif' | ||
mime: 'image/gif', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
}; |
@@ -11,6 +11,4 @@ 'use strict'; | ||
if (data[0] !== 0xFF || data[1] !== 0xD8) { | ||
// first marker of the file MUST be 0xFFD8 | ||
return; | ||
} | ||
// first marker of the file MUST be 0xFFD8 | ||
if (data[0] !== 0xFF || data[1] !== 0xD8) return; | ||
@@ -21,8 +19,5 @@ var offset = 2; | ||
if (data.length - offset < 2) return; | ||
// not a JPEG marker | ||
if (data[offset] !== 0xFF) return; | ||
if (data[offset] !== 0xFF) { | ||
// not a JPEG marker | ||
return; | ||
} | ||
var code = data[offset + 1]; | ||
@@ -63,3 +58,5 @@ var length; | ||
type: 'jpg', | ||
mime: 'image/jpeg' | ||
mime: 'image/jpeg', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
@@ -66,0 +63,0 @@ } |
@@ -18,10 +18,6 @@ 'use strict'; | ||
// check PNG signature | ||
if (!sliceEq(data, 0, SIG_PNG)) { | ||
return; | ||
} | ||
if (!sliceEq(data, 0, SIG_PNG)) return; | ||
// check that first chunk is IHDR | ||
if (!sliceEq(data, 12, SIG_IHDR)) { | ||
return; | ||
} | ||
if (!sliceEq(data, 12, SIG_IHDR)) return; | ||
@@ -32,4 +28,6 @@ return { | ||
type: 'png', | ||
mime: 'image/png' | ||
mime: 'image/png', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
}; |
@@ -17,5 +17,3 @@ 'use strict'; | ||
// signature + version | ||
if (!sliceEq(data, 0, SIG_8BPS)) { | ||
return; | ||
} | ||
if (!sliceEq(data, 0, SIG_8BPS)) return; | ||
@@ -26,4 +24,6 @@ return { | ||
type: 'psd', | ||
mime: 'image/vnd.adobe.photoshop' | ||
mime: 'image/vnd.adobe.photoshop', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
}; |
@@ -33,5 +33,3 @@ 'use strict'; | ||
if (values !== 1 || (type !== 3 && type !== 4)) { | ||
return null; | ||
} | ||
if (values !== 1 || (type !== 3 && type !== 4)) return null; | ||
@@ -47,5 +45,3 @@ return type === 3 ? | ||
// check TIFF signature | ||
if (!sliceEq(data, 0, SIG_1) && !sliceEq(data, 0, SIG_2)) { | ||
return; | ||
} | ||
if (!sliceEq(data, 0, SIG_1) && !sliceEq(data, 0, SIG_2)) return; | ||
@@ -89,5 +85,7 @@ var is_big_endian = (data[0] === 77 /* 'MM' */); | ||
type: 'tiff', | ||
mime: 'image/tiff' | ||
mime: 'image/tiff', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
} | ||
}; |
@@ -28,3 +28,5 @@ 'use strict'; | ||
type: 'webp', | ||
mime: 'image/webp' | ||
mime: 'image/webp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
@@ -37,5 +39,3 @@ } | ||
if (data[16 + 4] !== 0x2F) { | ||
return; | ||
} | ||
if (data[16 + 4] !== 0x2F) return; | ||
@@ -48,3 +48,5 @@ var bits = readUInt32LE(data, 16 + 5); | ||
type: 'webp', | ||
mime: 'image/webp' | ||
mime: 'image/webp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
@@ -63,3 +65,5 @@ } | ||
type: 'webp', | ||
mime: 'image/webp' | ||
mime: 'image/webp', | ||
wUnits: 'px', | ||
hUnits: 'px' | ||
}; | ||
@@ -66,0 +70,0 @@ } |
@@ -10,4 +10,5 @@ 'use strict'; | ||
psd: require('./parse_stream/psd'), | ||
svg: require('./parse_stream/svg'), | ||
tiff: require('./parse_stream/tiff'), | ||
webp: require('./parse_stream/webp') | ||
}; |
@@ -10,4 +10,5 @@ 'use strict'; | ||
psd: require('./parse_sync/psd'), | ||
svg: require('./parse_sync/svg'), | ||
tiff: require('./parse_sync/tiff'), | ||
webp: require('./parse_sync/webp') | ||
}; |
{ | ||
"name": "probe-image-size", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "Get image size without full download (JPG, GIF, PNG, WebP, BMP, TIFF, PSD)", | ||
@@ -15,2 +15,3 @@ "keywords": [ | ||
"bmp", | ||
"svg", | ||
"psd" | ||
@@ -41,3 +42,3 @@ ], | ||
"coveralls": "^2.11.9", | ||
"eslint": "2.7.0", | ||
"eslint": "~2.13.1", | ||
"from2": "^2.1", | ||
@@ -44,0 +45,0 @@ "istanbul": "^0.4.1", |
@@ -9,3 +9,3 @@ probe-image-size | ||
> Get image size without full download. Supported image types: | ||
> JPG, GIF, PNG, WebP, BMP, TIFF, PSD. | ||
> JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD. | ||
@@ -29,3 +29,3 @@ | ||
probe('http://example.com/image.jpg', function (err, result) { | ||
console.log(result); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg' } | ||
console.log(result); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg', wUnits: 'px', hUnits: 'px' } | ||
}); | ||
@@ -36,3 +36,3 @@ | ||
probe({ url: 'http://example.com/image.jpg', timeout: 5000 }, function (err, result) { | ||
console.log(result); // => { width: xx, height: yy, length: zz, type: 'jpg', mime: 'image/jpeg' } | ||
console.log(result); // => { width: xx, height: yy, length: zz, type: 'jpg', mime: 'image/jpeg', wUnits: 'px', hUnits: 'px' } | ||
}); | ||
@@ -43,3 +43,3 @@ | ||
probe('http://example.com/image.jpg').then(function (result) { | ||
console.log(result); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg' } | ||
console.log(result); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg', wUnits: 'px', hUnits: 'px' } | ||
}); | ||
@@ -52,3 +52,4 @@ | ||
probe(input, function (err, result) { | ||
console.log(result); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg' } | ||
console.log(result); | ||
// => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg', wUnits: 'px', hUnits: 'px' } | ||
@@ -64,3 +65,3 @@ // terminate input, depends on stream type, | ||
console.log(probe.sync(data)); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg' } | ||
console.log(probe.sync(data)); // => { width: xx, height: yy, type: 'jpg', mime: 'image/jpeg', wUnits: 'px', hUnits: 'px' } | ||
``` | ||
@@ -89,3 +90,5 @@ | ||
type: ..., // image 'type' (usual file name extention) | ||
mime: ... // mime type | ||
mime: ..., // mime type | ||
wUnits: 'px', // width units type ('px' by default, can be different for SVG) | ||
hUnits: 'px', // height units type ('px' by default, can be different for SVG) | ||
} | ||
@@ -92,0 +95,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40270
27
1096
125