Socket
Socket
Sign inDemoInstall

image-size

Package Overview
Dependencies
0
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.3.1

3

lib/detector.js

@@ -12,6 +12,3 @@ 'use strict';

module.exports = function (buffer, filepath) {
var type, result;
buffer = buffer.slice(0, 16);
for (type in typeMap) {

@@ -18,0 +15,0 @@ result = typeMap[type](buffer, filepath);

7

lib/types.js
'use strict';
module.exports = [
'bmp',
'gif',
'jpg',
'png',
'gif',
'bmp',
'psd',
'jpg',
// 'svg',
'tiff',
'webp'
];

@@ -8,13 +8,16 @@ 'use strict';

// TO-DO: handle the following as well
// ffe3 - Samsung D500 JPEG
// TO-DO: handle all JFIFs
var validJFIFMarkers = {
'ffe0': '4a46494600', // standard jpeg
'ffe1': '4578696600', // camera jpeg, with EXIF data
'ffe8': '5350494646', // SPIFF jpeg
'ffdb': '0001010101', // Samsung D807 JPEG
'ffe0': '4a46494600', // Standard JPEG
'ffe1': '4578696600', // Camera JPEG, with EXIF data
'ffe2': '4943435f50', // Canon EOS-1D JPEG
'ffe3': '', // Samsung D500 JPEG
'ffe8': '5350494646', // SPIFF JPEG
'ffec': '4475636b79', // Photoshop JPEG
'ffe2': '4943435f50' // Canon EOS-1D JPEG
'ffed': '', // Adobe JPEG, Photoshop CMYK buffer
'ffee': '41646f6265' // Adobe JPEG, Unrecognised (Lightroom??)
};
var red = ['\x1B[31m', '\x1B[39m'];
function isJPG (buffer) { //, filepath

@@ -33,2 +36,12 @@ var SOIMarker = buffer.toString('hex', 0, 2);

var expected = JFIFMarker && validJFIFMarkers[JFIFMarker];
if (expected === '') {
console.warn(
red[0] +
'this looks like a unrecognised jpeg\n' +
'please report the issue here\n' +
red[1],
'\thttps://github.com/netroy/image-size/issues/new\n'
);
return false;
}
return (got === expected) || (JFIFMarker === 'ffdb');

@@ -45,3 +58,3 @@ }

function validateBuffer (buffer, i) {
// index should be withing buffer limits
// index should be within buffer limits
if (i > buffer.length) {

@@ -48,0 +61,0 @@ throw new TypeError('Corrupt JPG, exceeded buffer limits');

{
"name": "image-size",
"version": "0.3.0",
"version": "0.3.1",
"description": "get dimensions of any image file",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc