image-size
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -66,3 +66,3 @@ 'use strict'; | ||
// if (code === 256 || code === 257) { | ||
if (length === 1 && type === 3) { | ||
if (length === 1 && (type === 3 || type === 4)) { | ||
tags[code] = readValue(buffer, isBigEndian); | ||
@@ -69,0 +69,0 @@ } |
@@ -13,6 +13,17 @@ 'use strict'; | ||
function calculate (buffer) { | ||
var chunkHeader = buffer.toString('ascii', 12, 16); | ||
buffer = buffer.slice(20, 30); | ||
// Extended webp stream signature | ||
if (chunkHeader === 'VP8X') { | ||
var extendedHeader = buffer[0]; | ||
var validStart = (extendedHeader & 0xc0) === 0; | ||
var validEnd = (extendedHeader & 0x01) === 0; | ||
if (validStart && validEnd) { | ||
return calculateExtended(buffer); | ||
} else { | ||
return false; | ||
} | ||
} | ||
// Lossless webp stream signature | ||
@@ -32,2 +43,9 @@ if (chunkHeader === 'VP8 ' && buffer[0] !== 0x2f) { | ||
function calculateExtended (buffer) { | ||
return { | ||
'width': 1 + buffer.readUIntLE(4, 3), | ||
'height': 1 + buffer.readUIntLE(7, 3) | ||
} | ||
} | ||
function calculateLossless (buffer) { | ||
@@ -34,0 +52,0 @@ return { |
{ | ||
"name": "image-size", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "get dimensions of any image file", | ||
@@ -43,8 +43,8 @@ "main": "lib/index.js", | ||
"expect.js": "^0.3.1", | ||
"glob": "^6.0.1", | ||
"glob": "^7.1.1", | ||
"istanbul": "^0.4.0", | ||
"jshint": "^2.8.0", | ||
"mocha": "^2.3.4", | ||
"mocha": "^3.2.0", | ||
"sinon": "^1.17.2" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18223
488
0