Socket
Socket
Sign inDemoInstall

image-size

Package Overview
Dependencies
0
Maintainers
3
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.1 to 0.7.2

20

lib/types/jpg.js
'use strict';
var readUInt = require('../readUInt');
// NOTE: we only support baseline and progressive JPGs here

@@ -28,3 +30,3 @@ // due to the structure of the loader class, we only get a buffer

var TIFF_BYTE_ALIGN_BYTES = 2;
var MOTOROLA_BYTE_ALIGN = '4d4d';
var BIG_ENDIAN_BYTE_ALIGN = '4d4d';

@@ -39,7 +41,5 @@ // Each entry is exactly 12 bytes

// TODO: support intel byte alignment
// Consider byte alignment
var byteAlign = exifBlock.toString('hex', EXIF_HEADER_BYTES, EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES);
if (byteAlign !== MOTOROLA_BYTE_ALIGN) {
return;
}
var bigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN;

@@ -57,3 +57,3 @@ // TODO: assert that this contains 0x002A

var idfDirectoryEntries = exifBlock.readUInt16BE(offset);
var idfDirectoryEntries = readUInt(exifBlock, 16, offset, bigEndian);

@@ -67,7 +67,7 @@ var start;

var block = exifBlock.slice(start, end);
var tagNumber = block.readUInt16BE(0);
var tagNumber = readUInt(block, 16, 0, bigEndian);
// 0x0112 (decimal: 274) is the `orientation` tag ID
if (tagNumber === 274) {
var dataFormat = block.readUInt16BE(2);
var dataFormat = readUInt(block, 16, 2, bigEndian);
if (dataFormat !== 3) {

@@ -79,3 +79,3 @@ return;

// if there would more than 4 bytes in total it's a pointer
var numberOfComponents = block.readUInt32BE(4);
var numberOfComponents = readUInt(block, 32, 4, bigEndian);
if (numberOfComponents !== 1) {

@@ -85,3 +85,3 @@ return;

var orientation = block.readUInt16BE(8);
var orientation = readUInt(block, 16, 8, bigEndian);

@@ -88,0 +88,0 @@ return orientation;

@@ -15,7 +15,25 @@ 'use strict';

var units = {
'cm': 96/2.54,
'mm': 96/2.54/10,
'm': 96/2.54*100,
'pt': 96/72,
'pc': 96/72/12,
'em': 16,
'ex': 8,
};
function parseLength (len) {
var m = /([0-9.]+)([a-z]*)/.exec(len);
if (!m) {
return undefined;
}
return Math.round(parseFloat(m[1]) * (units[m[2]] || 1));
}
function parseViewbox (viewbox) {
var bounds = viewbox.split(' ');
return {
'width': parseInt(bounds[2], 10),
'height': parseInt(bounds[3], 10)
'width': parseLength(bounds[2]),
'height': parseLength(bounds[3])
};

@@ -29,4 +47,4 @@ }

return {
'width': width && parseInt(width[2], 10),
'height': height && parseInt(height[2], 10),
'width': width && parseLength(width[2]),
'height': height && parseLength(height[2]),
'viewbox': viewbox && parseViewbox(viewbox[2])

@@ -33,0 +51,0 @@ };

{
"name": "image-size",
"version": "0.7.1",
"version": "0.7.2",
"description": "get dimensions of any image file",

@@ -45,9 +45,9 @@ "main": "lib/index.js",

"coveralls": "3.0.2",
"eslint": "5.12.0",
"eslint": "5.13.0",
"expect.js": "0.3.1",
"glob": "7.1.3",
"mocha": "5.2.0",
"nyc": "13.1.0",
"sinon": "7.2.2"
"nyc": "13.3.0",
"sinon": "7.2.3"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc